Skip to content

[llvm-objcopy] Don't remove .gnu_debuglink section when using --strip-all #78919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion llvm/test/tools/llvm-objcopy/ELF/strip-all.test
Original file line number Diff line number Diff line change
Expand Up @@ -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