diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp index daf03810fd7bf..b6d77d17bae36 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 20f3c9addf556..ba27a3509c6a3 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