[PATCH] D93362: [llvm-elfabi] Support ELF file that lacks .gnu_hash section

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 20:57:57 PST 2020


pcc added inline comments.


================
Comment at: llvm/lib/InterfaceStub/ELFObjHandler.cpp:453
+  for (const Elf_Shdr &Sec : *SectionsOrError) {
+    if (Sec.sh_type == ELF::SHT_DYNSYM)
+      return Sec.sh_size / Sec.sh_entsize;
----------------
This code won't find the section header if section headers have been stripped. You'll need to bring back the code that you deleted and extend it to infer the number of symbols from the `.hash` section. In general you can expect a binary to have at least one of `.hash` or `.gnu.hash` if it has a symbol table because there isn't enough information to interpret the dynamic symbol table without a hash table and without reading the section headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93362



More information about the llvm-commits mailing list