[PATCH] D67078: [llvm-readelf] - Allow dumping the dynamic symbols when there is no program headers.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 06:42:27 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay, rupprecht.
Herald added a subscriber: seiya.

D62179 <https://reviews.llvm.org/D62179> introduced a regression. llvm-readelf lose the ability to dump the dynamic symbols
when there is .dynamic section with a DT_SYMTAB, but there are no program headers:
https://reviews.llvm.org/D62179#1652778

Below is a program flow before the D62179 <https://reviews.llvm.org/D62179> change:

1. Find SHT_DYNSYM.
2. Find there is no PT_DYNAMIC => don't try to parse it.
3. Print dynamic symbols using information about them found on step (1).

And after the change it became:

1. Find SHT_DYNSYM.
2. Find there is no PT_DYNAMIC => find SHT_DYNAMIC.
3. Parse dynamic table, but fail to handle the DT_SYMTAB because of the absence of the PT_LOAD. Report the "Virtual address is not in any segment" error.

This patch stops attempts to handle the DT_SYMTAB if we found the SHT_DYNSYM table.
It seems consistent with GNU readelf and also it seems reasonable because for dumping
dynamic symbols we need to know dynamic section size. Since there is no `DT_SYMTABSZ`
exist we take this information from the sections table. So why not take the rest information
we need from there too?


https://reviews.llvm.org/D67078

Files:
  test/tools/llvm-readobj/dyn-symbols.test
  tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67078.218356.patch
Type: text/x-patch
Size: 3930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190902/74454c45/attachment.bin>


More information about the llvm-commits mailing list