aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-02-26 15:52:39 +0000
committerNick Clifton <nickc@redhat.com>2021-02-26 15:52:39 +0000
commit0e12f6c8020062fa520b8e17be98bd84a473fc20 (patch)
treec5f8ae2bb9b49ee0b571e066edd0543292fe390d
parentf821878623bb86d38e6c1579799038f495d09b61 (diff)
downloadgdb-0e12f6c8020062fa520b8e17be98bd84a473fc20.zip
gdb-0e12f6c8020062fa520b8e17be98bd84a473fc20.tar.gz
gdb-0e12f6c8020062fa520b8e17be98bd84a473fc20.tar.bz2
Add support for decoding DWARF v5 DW_AT_addr_base tags.
* dwarf.c (display_debug_addr): Handle dwarf-5 .debug_addr bits.
-rw-r--r--binutils/ChangeLog4
-rw-r--r--binutils/dwarf.c39
2 files changed, 40 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index a73c60d..0a89ac2 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,9 @@
2021-02-26 Tom de Vries <tdevries@suse.de>
+ * dwarf.c (display_debug_addr): Handle dwarf-5 .debug_addr bits.
+
+2021-02-26 Tom de Vries <tdevries@suse.de>
+
PR 27390
* dwarf.c: (skip_attr_bytes): Add support for DW_FORM_str* and
DW_FORM_addrx*.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 9cc51c2..555e5e0 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -6063,8 +6063,8 @@ display_debug_macro (struct dwarf_section *section,
SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
if (version != 4 && version != 5)
{
- error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"),
- section->name);
+ error (_("Expected to find a version number of 4 or 5 in section %s but found %d instead\n"),
+ section->name, version);
return 0;
}
@@ -7416,6 +7416,7 @@ display_debug_addr (struct dwarf_section *section,
unsigned char *end;
unsigned int i;
unsigned int count;
+ unsigned char * header;
if (section->size == 0)
{
@@ -7456,6 +7457,7 @@ display_debug_addr (struct dwarf_section *section,
debug_addr_info [count]->addr_base = section->size;
qsort (debug_addr_info, count, sizeof (debug_info *), comp_addr_base);
+ header = section->start;
for (i = 0; i < count; i++)
{
unsigned int idx;
@@ -7466,7 +7468,38 @@ display_debug_addr (struct dwarf_section *section,
printf (_("\tIndex\tAddress\n"));
entry = section->start + debug_addr_info [i]->addr_base;
- end = section->start + debug_addr_info [i + 1]->addr_base;
+ if (debug_addr_info [i]->dwarf_version >= 5)
+ {
+ size_t header_size = entry - header;
+ unsigned char * curr_header = header;
+ dwarf_vma length;
+ int version;
+ int segment_selector_size;
+
+ if (header_size != 8 && header_size != 16)
+ {
+ warn (_("Corrupt %s section: expecting header size of 8 or 16, but found %ld instead\n"),
+ section->name, (long) header_size);
+ return 0;
+ }
+
+ SAFE_BYTE_GET_AND_INC (length, curr_header, 4, entry);
+ if (length == 0xffffffff)
+ SAFE_BYTE_GET (length, curr_header, 8, entry);
+ end = curr_header + length;
+
+ SAFE_BYTE_GET_AND_INC (version, curr_header, 2, entry);
+ if (version != 5)
+ warn (_("Corrupt %s section: expecting version number 5 in header but found %d instead\n"),
+ section->name, version);
+
+ SAFE_BYTE_GET_AND_INC (address_size, curr_header, 1, entry);
+ SAFE_BYTE_GET_AND_INC (segment_selector_size, curr_header, 1, entry);
+ address_size += segment_selector_size;
+ }
+ else
+ end = section->start + debug_addr_info [i + 1]->addr_base;
+ header = end;
idx = 0;
while (entry < end)
{