aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/dwarf.c10
2 files changed, 14 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 3b638c0..cd6b573 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,10 @@
2021-02-12 Tom de Vries <tdevries@suse.de>
+ * dwarf.c (display_debug_str_offsets): Handle multiple sets of
+ entries.
+
+2021-02-12 Tom de Vries <tdevries@suse.de>
+
* dwarf.c (process_debug_info): Print DWO ID.
2021-02-11 Alan Modra <amodra@gmail.com>
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c96613f..e55a7da 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7379,18 +7379,22 @@ display_debug_str_offsets (struct dwarf_section *section,
else
entry_length = 4;
+ unsigned char *entries_end;
if (length == 0)
{
/* This is probably an old style .debug_str_offset section which
just contains offsets and no header (and the first offset is 0). */
length = section->size;
curr = section->start;
+ entries_end = end;
printf (_(" Length: %#lx\n"), (unsigned long) length);
printf (_(" Index Offset [String]\n"));
}
else
{
+ entries_end = curr + length;
+
int version;
SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
if (version != 5)
@@ -7406,11 +7410,15 @@ display_debug_str_offsets (struct dwarf_section *section,
printf (_(" Index Offset [String]\n"));
}
- for (idx = 0; length >= entry_length && curr < end; idx++)
+ for (idx = 0; curr < entries_end; idx++)
{
dwarf_vma offset;
const unsigned char * string;
+ if (curr + entry_length > entries_end)
+ /* Not enough space to read one entry_length, give up. */
+ return 0;
+
SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, end);
if (dwo)
string = (const unsigned char *)