[MinGW] Implement the GNU ld options -S/--strip-debug
authorMartin Storsjo <martin@martin.st>
Fri, 29 Jun 2018 06:08:31 +0000 (06:08 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 29 Jun 2018 06:08:31 +0000 (06:08 +0000)
In this mode, we retain the symbol table, but skip the actual debug
information.

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

llvm-svn: 335947

lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test

index 3e285e7..27a5550 100644 (file)
@@ -149,6 +149,8 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
   if (auto *A = Args.getLastArg(OPT_pdb)) {
     Add("-debug");
     Add("-pdb:" + StringRef(A->getValue()));
+  } else if (Args.hasArg(OPT_strip_debug)) {
+    Add("-debug:symtab");
   } else if (!Args.hasArg(OPT_strip_all)) {
     Add("-debug:dwarf");
   }
index 7e15bcd..ad699f7 100644 (file)
@@ -35,6 +35,8 @@ def subs: S<"subsystem">, HelpText<"Specify subsystem">;
 def stack: S<"stack">;
 def strip_all: F<"strip-all">,
     HelpText<"Omit all symbol information from the output binary">;
+def strip_debug: F<"strip-debug">,
+    HelpText<"Omit all debug information, but keep symbol information">;
 def whole_archive: F<"whole-archive">,
     HelpText<"Include all object files for following archives">;
 def verbose: F<"verbose">, HelpText<"Verbose mode">;
@@ -72,3 +74,4 @@ def version: F<"version">, HelpText<"Display the version number and exit">;
 // Alias
 def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
 def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;
+def alias_strip_S: Flag<["-"], "S">, Alias<strip_debug>;
index e7c608a..35d3ccf 100644 (file)
@@ -90,6 +90,11 @@ RUN: ld.lld -### -m i386pep foo.o -s | FileCheck -check-prefix STRIP %s
 RUN: ld.lld -### -m i386pep foo.o --strip-all | FileCheck -check-prefix STRIP %s
 STRIP-NOT: -debug:dwarf
 
+RUN: ld.lld -### -m i386pep foo.o -S | FileCheck -check-prefix STRIP-DEBUG %s
+RUN: ld.lld -### -m i386pep foo.o --strip-debug | FileCheck -check-prefix STRIP-DEBUG %s
+STRIP-DEBUG: -debug:symtab
+STRIP-DEBUG-NOT: -debug:dwarf
+
 RUN: ld.lld -### -m i386pep foo.o -pdb out.pdb | FileCheck -check-prefix PDB %s
 PDB: -debug -pdb:out.pdb
 PDB-NOT: -debug:dwarf