[binutils-gdb] binutils: factorize handling of arch-specific DWARF augmentations
Jose E. Marchesi
jemarch@sourceware.org
Sat Jul 12 09:37:34 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=11d33617e04dc6c54274ce69640218efd26519f5
commit 11d33617e04dc6c54274ce69640218efd26519f5
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date: Sat Jul 12 10:56:45 2025 +0200
binutils: factorize handling of arch-specific DWARF augmentations
This patch factorizes the handling of architecture/machine specific
augmentation characters in CIEs.
Based on an idea proposed by Richard Earnshaw.
binutils/ChangeLog:
* dwarf.c (is_mach_augmentation_ftype): New type.
(is_mach_augmentation): New variable.
(is_nomach_augmentation): New function.
(is_aarch64_augmentation): Likewise.
(init_dwarf_by_elf_machine_code): Set is_mach_augmentation as
appropriate.
(init_dwarf_by_bfd_arch_and_mach): Likewise.
(read_cie): Handle architecture-specific augmentation characters
in a generic way.
Diff:
---
binutils/dwarf.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 89594b5f5f2..8540b28aa90 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -8582,6 +8582,8 @@ typedef struct Frame_Chunk
}
Frame_Chunk;
+typedef bool (*is_mach_augmentation_ftype) (char c);
+static is_mach_augmentation_ftype is_mach_augmentation;
typedef const char *(*dwarf_regname_lookup_ftype) (unsigned int);
static dwarf_regname_lookup_ftype dwarf_regnames_lookup_func;
static const char *const *dwarf_regnames;
@@ -8894,9 +8896,22 @@ init_dwarf_regnames_loongarch (void)
dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
+static bool
+is_nomach_augmentation (char c ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+
+static bool
+is_aarch64_augmentation (char c)
+{
+ return (c == 'B');
+}
+
void
init_dwarf_by_elf_machine_code (unsigned int e_machine)
{
+ is_mach_augmentation = is_nomach_augmentation;
dwarf_regnames_lookup_func = NULL;
is_aarch64 = false;
@@ -8918,6 +8933,7 @@ init_dwarf_by_elf_machine_code (unsigned int e_machine)
case EM_AARCH64:
init_dwarf_regnames_aarch64 ();
+ is_mach_augmentation = is_aarch64_augmentation;
break;
case EM_S390:
@@ -8944,6 +8960,7 @@ void
init_dwarf_by_bfd_arch_and_mach (enum bfd_architecture arch,
unsigned long mach)
{
+ is_mach_augmentation = is_nomach_augmentation;
dwarf_regnames_lookup_func = NULL;
is_aarch64 = false;
@@ -8971,6 +8988,7 @@ init_dwarf_by_bfd_arch_and_mach (enum bfd_architecture arch,
case bfd_arch_aarch64:
init_dwarf_regnames_aarch64();
+ is_mach_augmentation = is_aarch64_augmentation;
break;
case bfd_arch_s390:
@@ -9216,7 +9234,7 @@ read_cie (unsigned char *start, unsigned char *end,
fc->fde_encoding = *q++;
else if (*p == 'S')
;
- else if (*p == 'B')
+ else if (is_mach_augmentation (*p))
;
else
break;
More information about the Binutils-cvs
mailing list