[llvm-strip] Add support for -remove-section
This diff adds support for -remove-section to llvm-strip.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D46567
llvm-svn: 332081
diff --git a/llvm/tools/llvm-objcopy/StripOpts.td b/llvm/tools/llvm-objcopy/StripOpts.td
index 3266c89..1d7a1ae 100644
--- a/llvm/tools/llvm-objcopy/StripOpts.td
+++ b/llvm/tools/llvm-objcopy/StripOpts.td
@@ -10,3 +10,9 @@
def strip_debug : Flag<["-", "--"], "strip-debug">,
HelpText<"Remove debugging symbols only">;
+defm remove_section : Eq<"remove-section">,
+ MetaVarName<"section">,
+ HelpText<"Remove <section>">;
+
+def R : JoinedOrSeparate<["-"], "R">,
+ Alias<remove_section>;
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index e08648e..c71e2b9 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -528,6 +528,10 @@
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
if (!Config.StripDebug)
Config.StripAll = true;
+
+ for (auto Arg : InputArgs.filtered(STRIP_remove_section))
+ Config.ToRemove.push_back(Arg->getValue());
+
return Config;
}