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 change:
- Find SHT_DYNSYM.
- Find there is no PT_DYNAMIC => don't try to parse it.
- Print dynamic symbols using information about them found on step (1).
And after the change it became:
- Find SHT_DYNSYM.
- Find there is no PT_DYNAMIC => find SHT_DYNAMIC.
- 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 fixes the issue. For doing this it checks that the value of DT_SYMTAB was mapped to a segment. If not - it ignores it.