[PATCH] D60054: [llvm-objcopy] Add --keep-symbols option
Yi Kong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 1 11:13:24 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357418: [llvm-objcopy] Add --keep-symbols option (authored by kongyi, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60054?vs=193108&id=193137#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60054/new/
https://reviews.llvm.org/D60054
Files:
llvm/trunk/test/tools/llvm-objcopy/ELF/keep-symbol.test
llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
Index: llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
===================================================================
--- llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
+++ llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
@@ -207,6 +207,15 @@
MetaVarName<"symbol">;
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
+defm keep_symbols
+ : Eq<"keep-symbols",
+ "Reads a list of symbols from <filename> and runs as if "
+ "--keep-symbol=<symbol> is set for each one. <filename> "
+ "contains one symbol per line and may contain comments beginning with "
+ "'#'. Leading and trailing whitespace is stripped from each line. May "
+ "be repeated to read symbols from many files.">,
+ MetaVarName<"filename">;
+
def only_keep_debug
: Flag<["-", "--"], "only-keep-debug">,
HelpText<"Clear sections that would not be stripped by --strip-debug. "
Index: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
@@ -596,6 +596,10 @@
return std::move(E);
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol))
Config.SymbolsToKeep.emplace_back(Arg->getValue(), UseRegex);
+ for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbols))
+ if (Error E = addSymbolsFromFile(Config.SymbolsToKeep, DC.Alloc,
+ Arg->getValue(), UseRegex))
+ return std::move(E);
for (auto Arg : InputArgs.filtered(OBJCOPY_add_symbol)) {
Expected<NewSymbolInfo> NSI = parseNewSymbolInfo(Arg->getValue());
if (!NSI)
Index: llvm/trunk/test/tools/llvm-objcopy/ELF/keep-symbol.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/keep-symbol.test
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/keep-symbol.test
@@ -6,6 +6,13 @@
# RUN: llvm-readobj --symbols %t3 | FileCheck %s
# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=REGEX
+# RUN: echo 'foo' > %t.symbols
+# RUN: echo 'bar' >> %t.symbols
+# RUN: llvm-objcopy --discard-all --keep-symbols %t.symbols %t %t5
+# RUN: llvm-objcopy -K foo -N foo -N bar --keep-symbols %t.symbols -N baz %t %t6
+# RUN: llvm-readobj --symbols %t5 | FileCheck %s
+# RUN: llvm-readobj --symbols %t6 | FileCheck %s
+
!ELF
FileHeader:
Class: ELFCLASS64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60054.193137.patch
Type: text/x-patch
Size: 2451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190401/2ebd5cbf/attachment.bin>
More information about the llvm-commits
mailing list