[binutils] Fix printing of .debug_str_offsets
authorTom de Vries <tdevries@suse.de>
Fri, 12 Feb 2021 03:43:03 +0000 (04:43 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 12 Feb 2021 03:43:03 +0000 (04:43 +0100)
commit95abb3944c6a97aeddfe91ef09405cf0b9e8142b
tree56388e28f1ec73bf90759fc70cb29e5f8982e28a
parentd60f79984aecd7f72de6fdf2015100a7516c9ee2
[binutils] Fix printing of .debug_str_offsets

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
...

binutils/ChangeLog:

2021-02-12  Tom de Vries  <tdevries@suse.de>

* dwarf.c (display_debug_str_offsets): Handle multiple sets of
entries.
binutils/ChangeLog
binutils/dwarf.c