[PATCH] D37393: [llvm-objcopy] Add support for section indexes greater than SHN_LORESERVE

Roland McGrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 12:57:12 PDT 2017


mcgrathr requested changes to this revision.
mcgrathr added inline comments.
This revision now requires changes to proceed.


================
Comment at: tools/llvm-objcopy/Object.cpp:222
     StringRef Name = unwrapOrError(Sym.getName(StrTabData));
-    if (Sym.st_shndx != SHN_UNDEF) {
+    if (Sym.st_shndx != SHN_UNDEF && Sym.st_shndx < SHN_LORESERVE) {
       if (Sym.st_shndx >= Sections.size())
----------------
This fails to handle SHN_XINDEX correctly.  See its handling elsewhere in the code base, or read the ELF spec.

It's probably OK to just pass all other >= SHN_LORESERVE values through blindly, but I'm not sure it's the best idea.
Their meaning and appropriate handling depends on each specific value defined by a particular machine or OS.
For all the ones I'm familiar with, just passing it through is all you need to do.  But I'm not entirely sanguine about assuming that uniformly.
I think it's probably better to handle each known case individually, and error out for values we don't expect.


Repository:
  rL LLVM

https://reviews.llvm.org/D37393





More information about the llvm-commits mailing list