[PATCH] D69093: [llvm-objcopy] --add-symbol: fix crash if SHT_SYMTAB does not exist

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 08:38:35 PDT 2019


rupprecht added inline comments.


================
Comment at: llvm/tools/llvm-objcopy/ELF/Object.cpp:1550-1552
+        // Prefer .strtab to .shstrtab.
+        if (Obj.SectionNames != &Sec)
+          break;
----------------
MaskRay wrote:
> rupprecht wrote:
> > Should `.dynstr` also be avoided? Is it better to just check that the name is literally `.strtab`?
> .dynstr is avoided by `!(Sec.Flags & SHF_ALLOC)`. `.strtab` works as well but `Obj.SectionNames != &Sec` is more general. There are multiple ways to accomplish the samething. I just wanted to make the code less magical.
From: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#special_sections
> .strtab
> This section holds strings, most commonly the strings that represent the names associated with symbol table entries. If the file has a loadable segment that includes the symbol string table, the section's attributes will include the SHF_ALLOC bit; otherwise, that bit will be off.

So, `.strtab` can also be `SHF_ALLOC`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69093





More information about the llvm-commits mailing list