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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 09:26:05 PDT 2019


MaskRay added inline comments.


================
Comment at: test/tools/llvm-readobj/dyn-symbols.test:185
+      - Tag:   DT_SYMTAB
+        Value: 0
+      - Tag:   DT_NULL
----------------
The test is different from https://reviews.llvm.org/D62179#1652778

In https://reviews.llvm.org/D62179#1652778, there is no program headers (corrupted phdr), so toMappedAddr returns a nullptr. Here, DT_SYMTAB is 0. When the information from DT_SYMTAB and .dynsym conflict, we probably should let DT_DYNTAB win...


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1656
+      if (!DynSymRegion.EntSize) {
+        DynSymRegion.Addr = toMappedAddr(Dyn.getTag(), Dyn.getPtr());
+        DynSymRegion.EntSize = sizeof(Elf_Sym);
----------------
We probably should check whether `toMappedAddr` returns a nullptr - which is the case if there is no program headers. This approach may be better than

  if (!DynSymRegion.EntSize) {



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67078/new/

https://reviews.llvm.org/D67078





More information about the llvm-commits mailing list