[llvm] Make llvm-strip not eat the .gnu_debuglink section (PR #78919)
Felix Kellenbenz via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 05:49:07 PST 2024
https://github.com/felixkellenbenz updated https://github.com/llvm/llvm-project/pull/78919
>From fa754359b7e9092ba00c566d1e867beb12deb757 Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz <fe.kellenbenz.computer at outlook.de>
Date: Mon, 22 Jan 2024 00:49:21 +0100
Subject: [PATCH 1/3] Make llvm-strip not eat the .gnu_debuglink section
---
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index daf03810fd7bff..b6d77d17bae36c 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:
>From a5a93a442836b7ac9cd4e986e5e4eea2961e2e19 Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz <fe.kellenbenz.computer at outlook.de>
Date: Mon, 22 Jan 2024 10:37:22 +0100
Subject: [PATCH 2/3] Add test that checks if llvm-strip removes the
.gnu_debuglink section
---
llvm/test/tools/llvm-objcopy/ELF/strip-all.test | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
index 20f3c9addf556b..efc3d42f22953f 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
@@ -68,6 +68,8 @@ 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
>From 9f9e60a4243ed421efd7360293ad0ec931896ce5 Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz <fe.kellenbenz.computer at outlook.de>
Date: Mon, 22 Jan 2024 14:47:19 +0100
Subject: [PATCH 3/3] Add test to check that llvm-strip does not remove the
.gnu_debuglink section
---
llvm/test/tools/llvm-objcopy/ELF/strip-all.test | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
index efc3d42f22953f..ba27a3509c6a31 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
@@ -76,10 +76,11 @@ ProgramHeaders:
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