From 85985ed363c9045a79866b82a80577481f2947a9 Mon Sep 17 00:00:00 2001 From: Jake Ehrlich Date: Thu, 6 Dec 2018 02:03:53 +0000 Subject: [PATCH] [llvm-objcopy] Change --only-keep to --only-section I just hard core goofed when I wrote this and created a different name for no good reason. I'm failry aware of most "fresh" users of llvm-objcopy (that is, users which are not using it as a drop in replacement for GNU objcopy) and can say that only "-j" is being used by such people so this patch should strictly increase compatibility and not remove it. Differential Revision: https://reviews.llvm.org/D52180 llvm-svn: 348446 --- .../ELF/{basic-only-keep.test => basic-only-section.test} | 2 +- llvm/test/tools/llvm-objcopy/ELF/dump-section.test | 2 +- ...y-keep-remove.test => explicit-only-section-remove.test} | 2 +- .../ELF/{keep-only-keep.test => keep-only-section.test} | 2 +- .../ELF/{only-keep-many.test => only-section-many.test} | 0 ...p-remove-strtab.test => only-section-remove-strtab.test} | 2 +- ...rip-non-alloc.test => only-section-strip-non-alloc.test} | 2 +- ...ions-only-keep.test => strip-sections-only-section.test} | 2 +- llvm/tools/llvm-objcopy/CopyConfig.cpp | 4 ++-- llvm/tools/llvm-objcopy/CopyConfig.h | 2 +- llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp | 4 ++-- llvm/tools/llvm-objcopy/ObjcopyOpts.td | 6 +++--- 12 files changed, 15 insertions(+), 15 deletions(-) rename llvm/test/tools/llvm-objcopy/ELF/{basic-only-keep.test => basic-only-section.test} (91%) rename llvm/test/tools/llvm-objcopy/ELF/{explicit-only-keep-remove.test => explicit-only-section-remove.test} (89%) rename llvm/test/tools/llvm-objcopy/ELF/{keep-only-keep.test => keep-only-section.test} (90%) rename llvm/test/tools/llvm-objcopy/ELF/{only-keep-many.test => only-section-many.test} (100%) rename llvm/test/tools/llvm-objcopy/ELF/{only-keep-remove-strtab.test => only-section-remove-strtab.test} (87%) rename llvm/test/tools/llvm-objcopy/ELF/{only-keep-strip-non-alloc.test => only-section-strip-non-alloc.test} (86%) rename llvm/test/tools/llvm-objcopy/ELF/{strip-sections-only-keep.test => strip-sections-only-section.test} (87%) diff --git a/llvm/test/tools/llvm-objcopy/ELF/basic-only-keep.test b/llvm/test/tools/llvm-objcopy/ELF/basic-only-section.test similarity index 91% rename from llvm/test/tools/llvm-objcopy/ELF/basic-only-keep.test rename to llvm/test/tools/llvm-objcopy/ELF/basic-only-section.test index 2f1c5e0a5ae5..536a0fc4cca9 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/basic-only-keep.test +++ b/llvm/test/tools/llvm-objcopy/ELF/basic-only-section.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -only-keep=.test %t %t2 +# RUN: llvm-objcopy -only-section=.test %t %t2 # RUN: llvm-objcopy -j .test %t %t3 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s # RUN: diff %t2 %t3 diff --git a/llvm/test/tools/llvm-objcopy/ELF/dump-section.test b/llvm/test/tools/llvm-objcopy/ELF/dump-section.test index cf9accdfd512..8e66f65e04a7 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/dump-section.test +++ b/llvm/test/tools/llvm-objcopy/ELF/dump-section.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s > %t # RUN: llvm-objcopy -O binary -j .text %t %t2 -# RUN: llvm-objcopy -O binary -only-keep .text %t %t3 +# RUN: llvm-objcopy -O binary -only-section .text %t %t3 # RUN: llvm-objcopy --dump-section .text=%t4 %t %t5 # RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7 # RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS diff --git a/llvm/test/tools/llvm-objcopy/ELF/explicit-only-keep-remove.test b/llvm/test/tools/llvm-objcopy/ELF/explicit-only-section-remove.test similarity index 89% rename from llvm/test/tools/llvm-objcopy/ELF/explicit-only-keep-remove.test rename to llvm/test/tools/llvm-objcopy/ELF/explicit-only-section-remove.test index 10d49e10c09c..15a315906abf 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/explicit-only-keep-remove.test +++ b/llvm/test/tools/llvm-objcopy/ELF/explicit-only-section-remove.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -R=.test -only-keep=.test %t %t2 +# RUN: llvm-objcopy -R=.test -only-section=.test %t %t2 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s !ELF diff --git a/llvm/test/tools/llvm-objcopy/ELF/keep-only-keep.test b/llvm/test/tools/llvm-objcopy/ELF/keep-only-section.test similarity index 90% rename from llvm/test/tools/llvm-objcopy/ELF/keep-only-keep.test rename to llvm/test/tools/llvm-objcopy/ELF/keep-only-section.test index 7c546c8f6834..38aa52cc70f3 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/keep-only-keep.test +++ b/llvm/test/tools/llvm-objcopy/ELF/keep-only-section.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -keep-section=.test2 -only-keep=.test %t %t2 +# RUN: llvm-objcopy -keep-section=.test2 -only-section=.test %t %t2 # RUN: llvm-objcopy -j .test -keep-section=.test2 %t %t3 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s # RUN: diff %t2 %t3 diff --git a/llvm/test/tools/llvm-objcopy/ELF/only-keep-many.test b/llvm/test/tools/llvm-objcopy/ELF/only-section-many.test similarity index 100% rename from llvm/test/tools/llvm-objcopy/ELF/only-keep-many.test rename to llvm/test/tools/llvm-objcopy/ELF/only-section-many.test diff --git a/llvm/test/tools/llvm-objcopy/ELF/only-keep-remove-strtab.test b/llvm/test/tools/llvm-objcopy/ELF/only-section-remove-strtab.test similarity index 87% rename from llvm/test/tools/llvm-objcopy/ELF/only-keep-remove-strtab.test rename to llvm/test/tools/llvm-objcopy/ELF/only-section-remove-strtab.test index f6885c8e131c..e336181d9fa4 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/only-keep-remove-strtab.test +++ b/llvm/test/tools/llvm-objcopy/ELF/only-section-remove-strtab.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -R .symtab -R .strtab -only-keep=.test %t %t2 +# RUN: llvm-objcopy -R .symtab -R .strtab -only-section=.test %t %t2 # RUN: llvm-objcopy -j .test -R .strtab -R .symtab %t %t3 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s # RUN: diff %t2 %t3 diff --git a/llvm/test/tools/llvm-objcopy/ELF/only-keep-strip-non-alloc.test b/llvm/test/tools/llvm-objcopy/ELF/only-section-strip-non-alloc.test similarity index 86% rename from llvm/test/tools/llvm-objcopy/ELF/only-keep-strip-non-alloc.test rename to llvm/test/tools/llvm-objcopy/ELF/only-section-strip-non-alloc.test index bad00228492a..f61b4ae664c6 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/only-keep-strip-non-alloc.test +++ b/llvm/test/tools/llvm-objcopy/ELF/only-section-strip-non-alloc.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -strip-non-alloc -only-keep=.test %t %t2 +# RUN: llvm-objcopy -strip-non-alloc -only-section=.test %t %t2 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s !ELF diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-keep.test b/llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-section.test similarity index 87% rename from llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-keep.test rename to llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-section.test index 2c9400cf34c1..2c14a7272e3e 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-keep.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-sections-only-section.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-objcopy -strip-sections -only-keep=.test %t %t2 +# RUN: llvm-objcopy -strip-sections -only-section=.test %t %t2 # RUN: od -Ax -t x1 %t2 | FileCheck %s # RUN: od -Ax -t c %t2 | FileCheck %s -check-prefix=TEXT diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp index 73611778c936..24f0e29d4926 100644 --- a/llvm/tools/llvm-objcopy/CopyConfig.cpp +++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp @@ -315,8 +315,8 @@ DriverConfig parseObjcopyOptions(ArrayRef ArgsArr) { Config.ToRemove.push_back(Arg->getValue()); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_section)) Config.KeepSection.push_back(Arg->getValue()); - for (auto Arg : InputArgs.filtered(OBJCOPY_only_keep)) - Config.OnlyKeep.push_back(Arg->getValue()); + for (auto Arg : InputArgs.filtered(OBJCOPY_only_section)) + Config.OnlySection.push_back(Arg->getValue()); for (auto Arg : InputArgs.filtered(OBJCOPY_add_section)) Config.AddSection.push_back(Arg->getValue()); for (auto Arg : InputArgs.filtered(OBJCOPY_dump_section)) diff --git a/llvm/tools/llvm-objcopy/CopyConfig.h b/llvm/tools/llvm-objcopy/CopyConfig.h index f6585116cdf9..ce6ead80b7c5 100644 --- a/llvm/tools/llvm-objcopy/CopyConfig.h +++ b/llvm/tools/llvm-objcopy/CopyConfig.h @@ -61,7 +61,7 @@ struct CopyConfig { std::vector AddSection; std::vector DumpSection; std::vector KeepSection; - std::vector OnlyKeep; + std::vector OnlySection; std::vector SymbolsToGlobalize; std::vector SymbolsToKeep; std::vector SymbolsToLocalize; diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp index 7430b19c772b..3b9f62e9b5fe 100644 --- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -415,10 +415,10 @@ static void handleArgs(const CopyConfig &Config, Object &Obj, }; // Explicit copies: - if (!Config.OnlyKeep.empty()) { + if (!Config.OnlySection.empty()) { RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { // Explicitly keep these sections regardless of previous removes. - if (is_contained(Config.OnlyKeep, Sec.Name)) + if (is_contained(Config.OnlySection, Sec.Name)) return false; // Allow all implicit removes. diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td index 73985ef8f625..1f7e64e4091c 100644 --- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td +++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td @@ -78,9 +78,9 @@ defm redefine_symbol MetaVarName<"old=new">; defm keep_section : Eq<"keep-section", "Keep
">, MetaVarName<"section">; -defm only_keep : Eq<"only-keep", "Remove all but
">, - MetaVarName<"section">; -def j : JoinedOrSeparate<["-"], "j">, Alias; +defm only_section : Eq<"only-section", "Remove all but
">, + MetaVarName<"section">; +def j : JoinedOrSeparate<["-"], "j">, Alias; defm add_section : Eq<"add-section", "Make a section named
with the contents of .">,