[PATCH] D47414: [llvm-objcopy] Fix null symbol handling

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 29 07:25:42 PDT 2018


jhenderson added a comment.

Our tool is an auxiliary tool, to help with manipulating ELF files. It is not a verification tool, so we should not be trying to identify every single problem with the ELF, unless it makes it hard/impossible to do something (e.g. a link field refers to a non-existent section). The only two clients of the symbol index that we care about, as far as I am aware, are relocations (which can have symbols index 0, but in this case just refer to no symbol - we should already special case this, although we don't), and group sections (which shouldn't refer to index 0, but it doesn't really matter if they do, as we do nothing with that symbol except get its updated index). End users can't directly manipulate the null symbol.



================
Comment at: tools/llvm-objcopy/Object.cpp:219
   Symbols.erase(
       std::remove_if(std::begin(Symbols), std::end(Symbols),
                      [ToRemove](const SymPtr &Sym) { return ToRemove(*Sym); }),
----------------
How about `std::begin(Symbols)+1`? That's really simple, and will mean the null symbol is not removed.


Repository:
  rL LLVM

https://reviews.llvm.org/D47414





More information about the llvm-commits mailing list