[PATCH] D46029: [llvm-objcopy] Implement --redefine-sym option

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 18:16:31 PDT 2018


jakehehrlich added a comment.

Sorry, I realized I wanted this to be done a slightly more complicated way.



================
Comment at: tools/llvm-objcopy/Object.cpp:211
 
 void SymbolTableSection::localize(
     std::function<bool(const Symbol &)> ToLocalize) {
----------------
Can you turn this into a generalized 'foreach symbol' operation that allows you to modify the symbols in the table and use that instead of adding 'renameSymbol'? Both localize and renameSymbol can work in terms of that. That also will support things better going forward. The correction at the end of here is sufficient for any modification to the  symbols since the only invariant that we have to maintain is that local symbols come before non-local symbols.


================
Comment at: tools/llvm-objcopy/llvm-objcopy.cpp:117
   StringRef AddGnuDebugLink;
+  std::pair<StringRef, StringRef> Old2New;
   std::vector<StringRef> ToRemove;
----------------
Can you make this to something like "SymbolsToRename" and make it a StringMap instead? That way we can handle multiple instances of the flag.


================
Comment at: tools/llvm-objcopy/llvm-objcopy.cpp:390
+  if (InputArgs.hasArg(OBJCOPY_redefine_symbol)) {
+    StringRef Old2New = InputArgs.getLastArgValue(OBJCOPY_redefine_symbol);
+    if (!Old2New.contains('='))
----------------
It should be easy enough to modify this for a varible number of arguments by making Config.Old2New a StringMap and then inserting pairs produced by split.


Repository:
  rL LLVM

https://reviews.llvm.org/D46029





More information about the llvm-commits mailing list