[PATCH] D123798: [llvm-objcopy] llvm-strip option --only-keep-debug should suppress default --strip-all
John McIver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 14 12:27:13 PDT 2022
jmciver created this revision.
Herald added subscribers: abrachet, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a project: All.
jmciver published this revision for review.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
The following commit resolves Issue #54417. Fixes llvm-strip conditional command
line option logic to not enable --strip-all in the presence of
--only-keep-debug.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123798
Files:
llvm/test/tools/llvm-objcopy/COFF/only-keep-debug.test
llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -1313,8 +1313,9 @@
return std::move(E);
if (!InputArgs.hasArg(STRIP_no_strip_all) && !Config.StripDebug &&
- !Config.StripUnneeded && Config.DiscardMode == DiscardType::None &&
- !Config.StripAllGNU && Config.SymbolsToRemove.empty())
+ !Config.OnlyKeepDebug && !Config.StripUnneeded &&
+ Config.DiscardMode == DiscardType::None && !Config.StripAllGNU &&
+ Config.SymbolsToRemove.empty())
Config.StripAll = true;
if (Config.DiscardMode == DiscardType::All) {
Index: llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
===================================================================
--- llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
+++ llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
@@ -2,6 +2,9 @@
# RUN: llvm-objcopy --only-keep-debug %t1 %t1.dbg
# RUN: llvm-readelf -S -l -x .note1 -x .note2 -x .debug_abbrev -x .debug_frame -x .debug_info %t1.dbg | FileCheck %s
+# RUN: llvm-strip --only-keep-debug %t1
+# RUN: llvm-readelf -S -l -x .note1 -x .note2 -x .debug_abbrev -x .debug_frame -x .debug_info %t1 | FileCheck %s
+
## Check that SHT_NOTE and .debug* are kept, but others are changed to SHT_NOBITS.
## SHT_NOBITS sections do not occupy space in the output.
Index: llvm/test/tools/llvm-objcopy/COFF/only-keep-debug.test
===================================================================
--- llvm/test/tools/llvm-objcopy/COFF/only-keep-debug.test
+++ llvm/test/tools/llvm-objcopy/COFF/only-keep-debug.test
@@ -3,9 +3,8 @@
RUN: llvm-objcopy --only-keep-debug %t.in.exe %t.out.exe
RUN: llvm-readobj --sections %t.out.exe | FileCheck %s --check-prefix=SECTIONS
RUN: llvm-objdump -t %t.out.exe | FileCheck %s --check-prefix=SYMBOLS
-# Run llvm-strip with --strip-symbol on a non-existent symbol to prevent
-# defaulting to --strip-all.
-RUN: llvm-strip --only-keep-debug --strip-symbol foo %t.in.exe -o %t-strip.out.exe
+
+RUN: llvm-strip --only-keep-debug %t.in.exe -o %t-strip.out.exe
RUN: cmp %t.out.exe %t-strip.out.exe
Check that all non-debug/buildid sections with IMAGE_SCN_CNT_CODE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123798.422873.patch
Type: text/x-patch
Size: 2289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220414/0f1a362b/attachment.bin>
More information about the llvm-commits
mailing list