[llvm] 11ca56e - [llvm-objcopy] Don't remove .gnu_debuglink section when using --strip-all (#78919)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 00:12:19 PST 2024
Author: Felix Kellenbenz
Date: 2024-01-24T08:12:16Z
New Revision: 11ca56eaf1aaf4f7fba5d94562c6b6c0d4444bc3
URL: https://github.com/llvm/llvm-project/commit/11ca56eaf1aaf4f7fba5d94562c6b6c0d4444bc3
DIFF: https://github.com/llvm/llvm-project/commit/11ca56eaf1aaf4f7fba5d94562c6b6c0d4444bc3.diff
LOG: [llvm-objcopy] Don't remove .gnu_debuglink section when using --strip-all (#78919)
This fixes the issue mentioned here:
https://github.com/llvm/llvm-project/issues/57407
It prevents `llvm-objcopy` from removing the `.gnu _debuglink` section
when used with the `--strip-all` flag. Since `--strip-all` is the
default of `llvm-strip` the patch also prevents `llvm-strip` from
removing the `.gnu_debuglink` section.
Added:
Modified:
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
llvm/test/tools/llvm-objcopy/ELF/strip-all.test
Removed:
################################################################################
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index daf03810fd7bff2..b6d77d17bae36c5 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -450,6 +450,8 @@ static Error replaceAndRemoveSections(const CommonConfig &Config,
return false;
if (StringRef(Sec.Name).starts_with(".gnu.warning"))
return false;
+ if (StringRef(Sec.Name).starts_with(".gnu_debuglink"))
+ return false;
// We keep the .ARM.attribute section to maintain compatibility
// with Debian derived distributions. This is a bug in their
// patchset as documented here:
diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
index 20f3c9addf556b9..ba27a3509c6a31c 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
@@ -68,16 +68,19 @@ Sections:
Flags: [ ]
- Name: .gnu.warning.foo
Type: SHT_PROGBITS
+ - Name: .gnu_debuglink
+ Type: SHT_PROGBITS
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
FirstSec: non_alloc_in_segment
LastSec: non_alloc_in_segment
-# CHECK: SectionHeaderCount: 6
+# CHECK: SectionHeaderCount: 7
# CHECK: Name: non_alloc_in_segment
# CHECK: Name: .bss
# CHECK: Name: .text
# CHECK: Name: .gnu.warning.foo
+# CHECK: Name: .gnu_debuglink
# CHECK: Name: .shstrtab
More information about the llvm-commits
mailing list