summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-01-19 19:42:54 +0000
committerMartin Storsjo <martin@martin.st>2019-01-19 19:42:54 +0000
commite8305175b0f99566e429e1644f121ff0207fc7f0 (patch)
tree3d6dcbf57b58d51df3099d6dae17c185baa61281 /llvm/tools/llvm-objcopy
parent1868d88b2efd705a11f44f8bef1960599a2346c1 (diff)
downloadbcm5719-llvm-e8305175b0f99566e429e1644f121ff0207fc7f0.tar.gz
bcm5719-llvm-e8305175b0f99566e429e1644f121ff0207fc7f0.zip
[llvm-objcopy] [COFF] Implement --only-section
Differential Revision: https://reviews.llvm.org/D56873 llvm-svn: 351663
Diffstat (limited to 'llvm/tools/llvm-objcopy')
-rw-r--r--llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp b/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
index 60afbf7bb54..99929d10a1f 100644
--- a/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
@@ -33,6 +33,12 @@ static bool isDebugSection(const Section &Sec) {
static Error handleArgs(const CopyConfig &Config, Object &Obj) {
// Perform the actual section removals.
Obj.removeSections([&Config](const Section &Sec) {
+ // Contrary to --only-keep-debug, --only-section fully removes sections that
+ // aren't mentioned.
+ if (!Config.OnlySection.empty() &&
+ !is_contained(Config.OnlySection, Sec.Name))
+ return true;
+
if (Config.StripDebug || Config.StripAll || Config.StripAllGNU ||
Config.DiscardAll || Config.StripUnneeded) {
if (isDebugSection(Sec) &&
OpenPOWER on IntegriCloud