[llvm] r345068 - [llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy case sensitive to support both -s (--strip-all) and -S (--strip-debug).

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 11:46:34 PDT 2018


Author: rupprecht
Date: Tue Oct 23 11:46:33 2018
New Revision: 345068

URL: http://llvm.org/viewvc/llvm-project?rev=345068&view=rev
Log:
[llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy case sensitive to support both -s (--strip-all) and -S (--strip-debug).

Summary:
GNU strip supports both `-s` and `-S` as aliases for `--strip-all` and `--strip-debug`, respectfully.

As part of this, it turns out that strip/objcopy were accepting case insensitive command line args. I'm not sure if there was an explicit reason for this. The only others uses of this are llvm-cvtres/llvm-mt/llvm-lib, which are all tools specific for windows support. Forcing case sensitivity allows both aliases to exist, but seems like a good idea anyway.

And as a surprise test case adjustment, the llvm-strip unit test was running with `-keep=unavailable_symbol`, despite `keep` not be a valid flag for strip. This is because there is a flag `-K` which, when case insensitivity is permitted, allows it to be interpreted as `-K` = `eep=unavailable_symbol` (e.g. to allow `-Kfoo` == `--keep-symbol=foo`).

Reviewers: jakehehrlich, jhenderson, alexshap

Reviewed By: jakehehrlich

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D53163

Modified:
    llvm/trunk/test/tools/llvm-objcopy/strip-all.test
    llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
    llvm/trunk/tools/llvm-objcopy/StripOpts.td

Modified: llvm/trunk/test/tools/llvm-objcopy/strip-all.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/strip-all.test?rev=345068&r1=345067&r2=345068&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all.test Tue Oct 23 11:46:33 2018
@@ -39,12 +39,16 @@
 # RUN: llvm-objcopy -S %t9 %t9
 # RUN: cmp %t2 %t9
 
+# RUN: cp %t %t10
+# RUN: llvm-strip -s %t10
+# RUN: cmp %t2 %t10
+
 # Verify that a non-existent symbol table (after first call to llvm-strip)
 # can be handled correctly.
-# RUN: cp %t %t9
-# RUN: llvm-strip --strip-all -keep=unavailable_symbol %t9
-# RUN: llvm-strip --strip-all -keep=unavailable_symbol %t9
-# RUN: cmp %t2 %t9
+# RUN: cp %t %t11
+# RUN: llvm-strip --strip-all --keep-symbol=unavailable_symbol %t11
+# RUN: llvm-strip --strip-all --keep-symbol=unavailable_symbol %t11
+# RUN: cmp %t2 %t11
 
 !ELF
 FileHeader:

Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=345068&r1=345067&r2=345068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Tue Oct 23 11:46:33 2018
@@ -61,7 +61,7 @@ static const opt::OptTable::Info Objcopy
 
 class ObjcopyOptTable : public opt::OptTable {
 public:
-  ObjcopyOptTable() : OptTable(ObjcopyInfoTable, true) {}
+  ObjcopyOptTable() : OptTable(ObjcopyInfoTable) {}
 };
 
 enum StripID {
@@ -90,7 +90,7 @@ static const opt::OptTable::Info StripIn
 
 class StripOptTable : public opt::OptTable {
 public:
-  StripOptTable() : OptTable(StripInfoTable, true) {}
+  StripOptTable() : OptTable(StripInfoTable) {}
 };
 
 enum SectionFlag {

Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=345068&r1=345067&r2=345068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Tue Oct 23 11:46:33 2018
@@ -19,6 +19,9 @@ def p : Flag<[ "-" ], "p">, Alias<preser
 def strip_all : Flag<["-", "--"], "strip-all">,
                 HelpText<"Remove non-allocated sections other than .gnu.warning* sections">;
 
+def s : Flag<["-"], "s">,
+        Alias<strip_all>;
+
 def strip_debug : Flag<["-", "--"], "strip-debug">,
                   HelpText<"Remove debugging symbols only">;
 




More information about the llvm-commits mailing list