[llvm] b77533f - [llvm-strip] Support grouped options in llvm-strip
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 13:37:23 PDT 2021
Author: Daniel RodrÃguez Troitiño
Date: 2021-07-01T13:36:45-07:00
New Revision: b77533fb70ac6388955ee34a1d1e96ba05b6b01f
URL: https://github.com/llvm/llvm-project/commit/b77533fb70ac6388955ee34a1d1e96ba05b6b01f
DIFF: https://github.com/llvm/llvm-project/commit/b77533fb70ac6388955ee34a1d1e96ba05b6b01f.diff
LOG: [llvm-strip] Support grouped options in llvm-strip
GNU and Apple `strip` implementations seems to support grouped options.
Enable the support for grouped options introduced in
https://reviews.llvm.org/D83639 for `llvm-strip` invocations.
Includes test that checks that both the grouped and non grouped
invocations produces the same result.
Reviewed By: alexander-shaposhnikov, MaskRay
Differential Revision: https://reviews.llvm.org/D105249
Added:
llvm/test/tools/llvm-objcopy/grouped-options.test
Modified:
llvm/tools/llvm-objcopy/ConfigManager.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objcopy/grouped-options.test b/llvm/test/tools/llvm-objcopy/grouped-options.test
new file mode 100644
index 000000000000..2644030426b0
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/grouped-options.test
@@ -0,0 +1,53 @@
+# This test checks that both grouped and ungrouped options (-S -x and -Sx)
+# produce exactly the same result given the same input.
+#
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-strip -S -x -o %t-strip-separated %t
+# RUN: llvm-strip -Sx -o %t-strip-grouped %t
+# RUN: cmp %t-strip-separated %t-strip-grouped
+
+# RUN: llvm-objcopy -S -x %t %t-objcopy-separated
+# RUN: llvm-objcopy -Sx %t %t-objcopy-grouped
+# RUN: cmp %t-objcopy-separated %t-objcopy-grouped
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .debugGlobal
+ Type: SHT_PROGBITS
+ Content: "00000000"
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Address: 0x1000
+ AddressAlign: 0x0000000000000010
+ Size: 64
+Symbols:
+ - Name: Local
+ Type: STT_FUNC
+ Section: .text
+ Value: 0x1000
+ Size: 8
+ - Name: LocalSection
+ Type: STT_SECTION
+ Section: .text
+ - Name: LocalFile
+ Type: STT_FILE
+ - Name: Global
+ Type: STT_FUNC
+ Size: 8
+ Section: .text
+ Value: 0x1010
+ Binding: STB_GLOBAL
+ - Name: Weak
+ Type: STT_FUNC
+ Size: 8
+ Section: .text
+ Value: 0x1008
+ - Name: debugGlobal
+ Section: .debugGlobal
+ Binding: STB_GLOBAL
diff --git a/llvm/tools/llvm-objcopy/ConfigManager.cpp b/llvm/tools/llvm-objcopy/ConfigManager.cpp
index 70939ee89667..2f04e70dd6ff 100644
--- a/llvm/tools/llvm-objcopy/ConfigManager.cpp
+++ b/llvm/tools/llvm-objcopy/ConfigManager.cpp
@@ -60,7 +60,9 @@ static const opt::OptTable::Info ObjcopyInfoTable[] = {
class ObjcopyOptTable : public opt::OptTable {
public:
- ObjcopyOptTable() : OptTable(ObjcopyInfoTable) {}
+ ObjcopyOptTable() : OptTable(ObjcopyInfoTable) {
+ setGroupedShortOptions(true);
+ }
};
enum InstallNameToolID {
@@ -164,7 +166,7 @@ static const opt::OptTable::Info StripInfoTable[] = {
class StripOptTable : public opt::OptTable {
public:
- StripOptTable() : OptTable(StripInfoTable) {}
+ StripOptTable() : OptTable(StripInfoTable) { setGroupedShortOptions(true); }
};
} // namespace
More information about the llvm-commits
mailing list