Skip to content

Commit 11ca56e

Browse files
[llvm-objcopy] Don't remove .gnu_debuglink section when using --strip-all (#78919)
This fixes the issue mentioned here: #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.
1 parent c125965 commit 11ca56e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ static Error replaceAndRemoveSections(const CommonConfig &Config,
450450
return false;
451451
if (StringRef(Sec.Name).starts_with(".gnu.warning"))
452452
return false;
453+
if (StringRef(Sec.Name).starts_with(".gnu_debuglink"))
454+
return false;
453455
// We keep the .ARM.attribute section to maintain compatibility
454456
// with Debian derived distributions. This is a bug in their
455457
// patchset as documented here:

llvm/test/tools/llvm-objcopy/ELF/strip-all.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,19 @@ Sections:
6868
Flags: [ ]
6969
- Name: .gnu.warning.foo
7070
Type: SHT_PROGBITS
71+
- Name: .gnu_debuglink
72+
Type: SHT_PROGBITS
7173
ProgramHeaders:
7274
# Use an arbitrary segment type to show that the segment type is unimportant.
7375
- Type: 0x61234567
7476
FirstSec: non_alloc_in_segment
7577
LastSec: non_alloc_in_segment
7678

77-
# CHECK: SectionHeaderCount: 6
79+
# CHECK: SectionHeaderCount: 7
7880

7981
# CHECK: Name: non_alloc_in_segment
8082
# CHECK: Name: .bss
8183
# CHECK: Name: .text
8284
# CHECK: Name: .gnu.warning.foo
85+
# CHECK: Name: .gnu_debuglink
8386
# CHECK: Name: .shstrtab

0 commit comments

Comments
 (0)