[PATCH][binutils] Fix printing of .debug_str_offsets
Tom de Vries
tdevries@suse.de
Thu Feb 11 13:58:26 GMT 2021
More information about the Binutils mailing list
Thu Feb 11 13:58:26 GMT 2021
- Previous message (by thread): [PATCH][binutils] Print DWO ID
- Next message (by thread): [PATCH][binutils] Fix printing of .debug_str_offsets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
With exec:
...
$ clang -gdwarf-5 ./src/gdb/testsuite/gdb.dwarf2/fission-mix*.c
...
we have:
...
$ readelf -w a.out
...
Contents of the .debug_str_offsets section:
Length: 0x24
Version: 0x5
Index Offset [String]
0 1d0 clang version 10.0.1
1 1e6 src/gdb/testsuite/gdb.dwarf2/fission-mix-2.c
2 213 /home/vries/gdb_versions/devel
3 232 bar
4 236 x
5 61 int
6 238 s
7 23a func2
8 2c ild/BUILD/glibc-2.26/csu
9 5 sdeps/x86_64/start.S
10 1d0 clang version 10.0.1
11 240 src/gdb/testsuite/gdb.dwarf2/fission-mix.c
12 213 /home/vries/gdb_versions/devel
13 26b foo
14 236 x
15 61 int
16 238 s
17 26f func
18 274 main
19 279 arg
...
The section consists of two parts, one for each CU, each with a header, but
the printing only reads the first header as a header, and prints the second
header as:
...
8 2c ild/BUILD/glibc-2.26/csu
9 5 sdeps/x86_64/start.S
...
Fix this in display_debug_str_offsets such that we have:
...
6 238 s
7 23a func2
Length: 0x2c
Version: 0x5
Index Offset [String]
0 1d0 clang version 10.0.1
1 240 src/gdb/testsuite/gdb.dwarf2/fission-mix.c
...
OK for trunk?
Thanks,
- Tom
[binutils] Fix printing of .debug_str_offsets
binutils/ChangeLog:
2021-02-11 Tom de Vries <tdevries@suse.de>
* dwarf.c (display_debug_str_offsets): Handle multiple sets of
entries.
---
binutils/dwarf.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c96613f37e6..e55a7daa8fe 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 *)
- Previous message (by thread): [PATCH][binutils] Print DWO ID
- Next message (by thread): [PATCH][binutils] Fix printing of .debug_str_offsets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list