[PATCH] D47052: [llvm-objcopy] Fix the behavior of --strip-* and --keep-symbol

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 14:46:57 PDT 2018


alexshap added inline comments.


================
Comment at: tools/llvm-objcopy/llvm-objcopy.cpp:226
 
+  bool KeepSymbolsTable = false;
+  if (Obj.SymbolTable) {
----------------
jakehehrlich wrote:
> If possible I'd prefer this come after and I'd prefer not using the functions in removeSymbols to keep state. I think it's sufficient to just check that SymbolsToKeep is non-empty for the single explicit section keep.
@jakehehrich, Jake, so basically binutils objcopy does the following (as i already tried to explain in my previous comment) (if I'm not mistaken or not missing smth): if at least one symbol specified by -K is kept, then all the local symbols are kept as well, and the symbols table / strings table are not getting removed.
So it looks like if we want to repeat this logic (in particular regarding the local symbols), we can either keep track of this state (what's going on right now), or we can scan the symbols beforehand and check if it contains any of the symbols specified by -K. 
(checking if the symbols table is empty or not is not sufficient since (as i mentioned above) we are not allowed to remove the local symbols anyway, so it'll be  non-empty anyway in this case.
What are your thoughts / preferences ?





Repository:
  rL LLVM

https://reviews.llvm.org/D47052





More information about the llvm-commits mailing list