[lld] Relax needsInterpSection condition (PR #161374)
Hugues Morisset via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 06:18:58 PDT 2025
https://github.com/izissise created https://github.com/llvm/llvm-project/pull/161374
This allows having executable shared objects
Add dynlinker shared test
#160059
I couldn't see a test failure, I'm not sure it is correctly setup any help appreciated
>From 93a62d3119d48fbd3f6168db78fdd2f3b2d3bb8b Mon Sep 17 00:00:00 2001
From: Hugues Morisset <morisset.hugues at gmail.com>
Date: Tue, 30 Sep 2025 15:12:37 +0200
Subject: [PATCH] Relax needsInterpSection condition
This allows having executable shared objects
Add dynlinker shared test
---
lld/ELF/SyntheticSections.cpp | 2 +-
lld/test/ELF/dynamic-linker-shared.s | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 lld/test/ELF/dynamic-linker-shared.s
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 457a794a8c3a8..040911a8b5053 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -4543,7 +4543,7 @@ void PartitionIndexSection::writeTo(uint8_t *buf) {
}
static bool needsInterpSection(Ctx &ctx) {
- return !ctx.arg.relocatable && !ctx.arg.shared &&
+ return !ctx.arg.relocatable &&
!ctx.arg.dynamicLinker.empty() && ctx.script->needsInterpSection();
}
diff --git a/lld/test/ELF/dynamic-linker-shared.s b/lld/test/ELF/dynamic-linker-shared.s
new file mode 100644
index 0000000000000..de48fee72d8f6
--- /dev/null
+++ b/lld/test/ELF/dynamic-linker-shared.s
@@ -0,0 +1,6 @@
+; REQUIRES: x86_64
+; RUN: echo 'int main() { return 0; }' > %t.c
+; RUN: %clang -c -o %t.o %t.c
+; RUN: %ld.lld -shared %t.o /usr/lib/x86_64-linux-gnu/Scrt1.o --dynamic-linker=/lib64/ld-linux-x86-64.so.2 -o %t.so
+; RUN: llvm-readobj --program-headers %t.so | FileCheck %s
+; CHECK: PT_INTERP
More information about the llvm-commits
mailing list