Skip to content

Commit 05a3f99

Browse files
committed
[llvm-strip] Implement --keep-file-symbols
Differential revision: https://reviews.llvm.org/D57582 llvm-svn: 352878
1 parent 971d476 commit 05a3f99

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

llvm/test/tools/llvm-objcopy/ELF/keep-file-symbols.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# RUN: llvm-objcopy --keep-file-symbols --strip-symbol foo %t %t2
55
# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=STRIP
66

7+
# RUN: llvm-strip --keep-file-symbols %t -o %t3
8+
# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=STRIPALL
9+
# RUN: llvm-strip --keep-file-symbols --strip-symbol foo %t -o %t4
10+
# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=STRIP
11+
712
!ELF
813
FileHeader:
914
Class: ELFCLASS64

llvm/tools/llvm-objcopy/CopyConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ DriverConfig parseStripOptions(ArrayRef<const char *> ArgsArr) {
479479
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
480480
Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
481481
Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
482+
Config.KeepFileSymbols = InputArgs.hasArg(STRIP_keep_file_symbols);
482483

483484
for (auto Arg : InputArgs.filtered(STRIP_keep_section))
484485
Config.KeepSection.push_back(Arg->getValue());

llvm/tools/llvm-objcopy/StripOpts.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ defm keep_section : Eq<"keep-section", "Keep <section>">,
5959
MetaVarName<"section">;
6060
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
6161
MetaVarName<"symbol">;
62+
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
63+
HelpText<"Do not remove file symbols">;
64+
6265
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
6366

6467
def discard_locals : Flag<["-", "--"], "discard-locals">,

0 commit comments

Comments
 (0)