aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binutils/ChangeLog16
-rw-r--r--binutils/dwarf.c43
2 files changed, 51 insertions, 8 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8251db2..9aace13 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,21 @@
2019-11-22 Andrew Burgess <andrew.burgess@embecosm.com>
+ * dwarf.c (typedef dwarf_regname_lookup_ftype): New typedef.
+ (dwarf_regnames_lookup_func): New static global.
+ (init_dwarf_regnames_i386): Set dwarf_regnames_lookup_func.
+ (init_dwarf_regnames_iamcu): Likewise.
+ (init_dwarf_regnames_x86_64): Likewise.
+ (init_dwarf_regnames_aarch64): Likewise.
+ (init_dwarf_regnames_s390): Likewise.
+ (init_dwarf_regnames_riscv): Likewise.
+ (init_dwarf_regnames_by_elf_machine_code): Reset
+ dwarf_regnames_lookup_func to NULL.
+ (init_dwarf_regnames_by_bfd_arch_and_mach): Likewise.
+ (regname_internal_by_table_only): New function.
+ (regname): Make use of dwarf_regnames_lookup_func.
+
+2019-11-22 Andrew Burgess <andrew.burgess@embecosm.com>
+
* dwarf.c (init_dwarf_regnames_i386): Make static.
(init_dwarf_regnames_iamcu): Make static.
(init_dwarf_regnames_x86_64): Make static.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index fc73fa7..483d7c0 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -38,6 +38,7 @@
#define MIN(a, b) ((a) < (b) ? (a) : (b))
static const char *regname (unsigned int regno, int row);
+static const char *regname_internal_by_table_only (unsigned int regno);
static int have_frame_base;
static int need_base_address;
@@ -7360,9 +7361,12 @@ typedef struct Frame_Chunk
}
Frame_Chunk;
+typedef const char *(*dwarf_regname_lookup_ftype) (unsigned int);
+static dwarf_regname_lookup_ftype dwarf_regnames_lookup_func;
static const char *const *dwarf_regnames;
static unsigned int dwarf_regnames_count;
+
/* A marker for a col_type that means this column was never referenced
in the frame info. */
#define DW_CFA_unreferenced (-1)
@@ -7469,6 +7473,7 @@ init_dwarf_regnames_i386 (void)
{
dwarf_regnames = dwarf_regnames_i386;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static void
@@ -7476,6 +7481,7 @@ init_dwarf_regnames_iamcu (void)
{
dwarf_regnames = dwarf_regnames_iamcu;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_x86_64[] =
@@ -7515,6 +7521,7 @@ init_dwarf_regnames_x86_64 (void)
{
dwarf_regnames = dwarf_regnames_x86_64;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_aarch64[] =
@@ -7542,6 +7549,7 @@ init_dwarf_regnames_aarch64 (void)
{
dwarf_regnames = dwarf_regnames_aarch64;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_s390[] =
@@ -7566,6 +7574,7 @@ init_dwarf_regnames_s390 (void)
{
dwarf_regnames = dwarf_regnames_s390;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_s390);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_riscv[] =
@@ -7587,11 +7596,14 @@ init_dwarf_regnames_riscv (void)
{
dwarf_regnames = dwarf_regnames_riscv;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_riscv);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
void
init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine)
{
+ dwarf_regnames_lookup_func = NULL;
+
switch (e_machine)
{
case EM_386:
@@ -7632,6 +7644,8 @@ void
init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch,
unsigned long mach)
{
+ dwarf_regnames_lookup_func = NULL;
+
switch (arch)
{
case bfd_arch_i386:
@@ -7674,18 +7688,31 @@ init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch,
}
static const char *
-regname (unsigned int regno, int row)
+regname_internal_by_table_only (unsigned int regno)
{
- static char reg[64];
-
- if (dwarf_regnames
+ if (dwarf_regnames != NULL
&& regno < dwarf_regnames_count
&& dwarf_regnames [regno] != NULL)
+ return dwarf_regnames [regno];
+
+ return NULL;
+}
+
+static const char *
+regname (unsigned int regno, int name_only_p)
+{
+ static char reg[64];
+
+ const char *name = NULL;
+
+ if (dwarf_regnames_lookup_func != NULL)
+ name = dwarf_regnames_lookup_func (regno);
+
+ if (name != NULL)
{
- if (row)
- return dwarf_regnames [regno];
- snprintf (reg, sizeof (reg), "r%d (%s)", regno,
- dwarf_regnames [regno]);
+ if (name_only_p)
+ return name;
+ snprintf (reg, sizeof (reg), "r%d (%s)", regno, name);
}
else
snprintf (reg, sizeof (reg), "r%d", regno);