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