Index: test/tools/llvm-objcopy/COFF/only-section.test =================================================================== --- test/tools/llvm-objcopy/COFF/only-section.test +++ test/tools/llvm-objcopy/COFF/only-section.test @@ -9,6 +9,9 @@ RUN: llvm-objcopy --only-section .debug_discardable --only-section .text --strip-debug %t.in.exe %t.combination.exe RUN: llvm-objdump --section-headers -t %t.combination.exe | FileCheck %s --check-prefixes=SECTIONS,SECTIONS-TEXT,SYMBOLS,SYMBOLS-TEXT +RUN: llvm-objcopy --only-section .debug_discardable --only-section .text -g %t.in.exe %t.combination_g.exe +RUN: llvm-objdump --section-headers -t %t.combination_g.exe | FileCheck %s --check-prefixes=SECTIONS,SECTIONS-TEXT,SYMBOLS,SYMBOLS-TEXT + SECTIONS: Sections: SECTIONS-NEXT: Idx Name SECTIONS-DEBUG-NEXT: .debug_discardable Index: test/tools/llvm-objcopy/COFF/strip-debug.test =================================================================== --- test/tools/llvm-objcopy/COFF/strip-debug.test +++ test/tools/llvm-objcopy/COFF/strip-debug.test @@ -7,6 +7,10 @@ # RUN: llvm-objdump --section-headers %t.out.o | FileCheck %s --check-prefixes=SECTIONS # RUN: llvm-objdump -t %t.out.o | FileCheck %s --check-prefixes=SYMBOLS # +# RUN: llvm-objcopy -g %t.in.o %t.out_g.o +# RUN: llvm-objdump --section-headers %t.out_g.o | FileCheck %s --check-prefixes=SECTIONS +# RUN: llvm-objdump -t %t.out_g.o | FileCheck %s --check-prefixes=SYMBOLS +# # Test that --strip-all, --strip-all-gnu, --discard-all and --strip-unneeded, # plus llvm-strip without arguments all produce a similiar set of sections # (while they remove symbols differently). Index: test/tools/llvm-objcopy/ELF/help-message.test =================================================================== --- test/tools/llvm-objcopy/ELF/help-message.test +++ test/tools/llvm-objcopy/ELF/help-message.test @@ -4,6 +4,7 @@ # RUN: not llvm-objcopy -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s # RUN: not llvm-objcopy --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s # RUN: not llvm-objcopy --strip-debug 2>&1 | FileCheck %s --check-prefix=NO-INPUT-FILES +# RUN: not llvm-objcopy -g 2>&1 | FileCheck %s --check-prefix=NO-INPUT-FILES # RUN: llvm-strip -help | FileCheck --check-prefix=STRIP-USAGE %s # RUN: llvm-strip --help | FileCheck --check-prefix=STRIP-USAGE %s Index: test/tools/llvm-objcopy/ELF/strip-debug-and-remove.test =================================================================== --- test/tools/llvm-objcopy/ELF/strip-debug-and-remove.test +++ test/tools/llvm-objcopy/ELF/strip-debug-and-remove.test @@ -6,6 +6,8 @@ # RUN: llvm-objcopy --strip-debug --remove-section=.text.bar %t1 %t1 # RUN: cmp %t %t1 +# RUN: llvm-objcopy -g --remove-section=.text.bar %t %t2 +# RUN: cmp %t %t2 !ELF FileHeader: Index: test/tools/llvm-objcopy/ELF/strip-debug.test =================================================================== --- test/tools/llvm-objcopy/ELF/strip-debug.test +++ test/tools/llvm-objcopy/ELF/strip-debug.test @@ -6,6 +6,10 @@ # Verify that the previous run of llvm-objcopy has not modified the input. # RUN: cmp %t %t3 +# RUN: llvm-objcopy -g %t %t2g +# Verify that --strip-debug and -g produce the same output +# RUN: cmp %t2 %t2g + # RUN: llvm-strip --strip-debug %t3 # RUN: cmp %t2 %t3 @@ -23,6 +27,11 @@ # RUN: rm -f %t.a # RUN: llvm-ar crs %t.a %t +# RUN: llvm-objcopy --strip-debug %t.a %t2.a +# RUN: llvm-objcopy -g %t.a %t3.a +# Verify that --strip-debug and -g produce the same output +# RUN: cmp %t2.a %t3.a + # RUN: llvm-objcopy --strip-debug %t.a %t.a # RUN: llvm-ar p %t.a > %t7 # RUN: cmp %t2 %t7 @@ -34,6 +43,11 @@ # RUN: llvm-ar crs %t.multiple-stripped-obj.a %t2 %t.duplicate.stripped # RUN: rm -f %t.multiple-obj.a # RUN: llvm-ar crs %t.multiple-obj.a %t %t.duplicate +# RUN: llvm-objcopy --strip-debug %t.multiple-obj.a %t2.multiple-obj.stripped.a +# RUN: llvm-objcopy -g %t.multiple-obj.a %t3.multiple-obj.stripped.a +# Verify that --strip-debug and -g produce the same output +# RUN: cmp %t2.multiple-obj.stripped.a %t3.multiple-obj.stripped.a + # RUN: llvm-objcopy --strip-debug %t.multiple-obj.a %t.multiple-obj.stripped.a # RUN: llvm-ar p %t.multiple-stripped-obj.a > %t.multiple-stripped-obj.a.dump # RUN: llvm-ar p %t.multiple-obj.stripped.a > %t.multiple-obj.stripped.a.dump @@ -54,6 +68,7 @@ # RUN: cp %t.non-object.a %t.non-object.copy.a # RUN: not llvm-objcopy --strip-debug %t.non-object.a %t2.non-object.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT +# RUN: not llvm-objcopy -g %t.non-object.a %t3.non-object.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT # BAD-FORMAT: The file was not recognized as a valid object file @@ -64,6 +79,11 @@ # Copy %t to %t.thin.archive.member to avoid changing %t directly. # RUN: cp %t %t.thin.archive.member # RUN: llvm-ar crsT %t.thin.a %t.thin.archive.member +# RUN: llvm-objcopy --strip-debug %t.thin.a %t3.thin.a +# RUN: llvm-objcopy -g %t.thin.a %t4.thin.a +# Verify that --strip-debug and -g produce the same output +# RUN: cmp %t3.thin.a %t4.thin.a + # RUN: llvm-objcopy --strip-debug %t.thin.a %t2.thin.a # RUN: cat %t.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE # RUN: cat %t2.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE @@ -84,6 +104,9 @@ # RUN: cmp %s %t2.txt # RUN: cmp %t %t3.o +# RUN: not llvm-objcopy --strip-debug %t.non-object.thin.a %t.non-object.thin.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT +# RUN: not llvm-objcopy -g %t.non-object.thin.a %t.non-object.thin.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT + !ELF FileHeader: Class: ELFCLASS64 Index: tools/llvm-objcopy/ObjcopyOpts.td =================================================================== --- tools/llvm-objcopy/ObjcopyOpts.td +++ tools/llvm-objcopy/ObjcopyOpts.td @@ -95,6 +95,8 @@ HelpText<"Compatible with GNU objcopy's --strip-all">; def strip_debug : Flag<["-", "--"], "strip-debug">, HelpText<"Remove all debug information">; +def g : Flag<["-"], "g">, Alias, + HelpText<"Alias for --strip-debug">; def strip_dwo : Flag<["-", "--"], "strip-dwo">, HelpText<"Remove all DWARF .dwo sections from file">; def strip_sections : Flag<["-", "--"], "strip-sections">,