Index: test/tools/llvm-objcopy/ELF/keep-file-symbols.test =================================================================== --- test/tools/llvm-objcopy/ELF/keep-file-symbols.test +++ test/tools/llvm-objcopy/ELF/keep-file-symbols.test @@ -4,6 +4,11 @@ # RUN: llvm-objcopy --keep-file-symbols --strip-symbol foo %t %t2 # RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=STRIP +# RUN: llvm-strip --keep-file-symbols %t -o %t3 +# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=STRIPALL +# RUN: llvm-strip --keep-file-symbols --strip-symbol foo %t -o %t4 +# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=STRIP + !ELF FileHeader: Class: ELFCLASS64 Index: tools/llvm-objcopy/CopyConfig.cpp =================================================================== --- tools/llvm-objcopy/CopyConfig.cpp +++ tools/llvm-objcopy/CopyConfig.cpp @@ -479,6 +479,7 @@ Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded); Config.StripAll = InputArgs.hasArg(STRIP_strip_all); Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu); + Config.KeepFileSymbols = InputArgs.hasArg(STRIP_keep_file_symbols); for (auto Arg : InputArgs.filtered(STRIP_keep_section)) Config.KeepSection.push_back(Arg->getValue()); Index: tools/llvm-objcopy/StripOpts.td =================================================================== --- tools/llvm-objcopy/StripOpts.td +++ tools/llvm-objcopy/StripOpts.td @@ -59,6 +59,9 @@ MetaVarName<"section">; defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol ">, MetaVarName<"symbol">; +def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">, + HelpText<"Do not remove file symbols">; + def K : JoinedOrSeparate<["-"], "K">, Alias; def discard_locals : Flag<["-", "--"], "discard-locals">,