[lld] f8cb78e - [ELF] Don't define __rela_iplt_start for -pie/-shared
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 11:31:19 PDT 2021
Author: Fangrui Song
Date: 2021-07-15T11:31:11-07:00
New Revision: f8cb78e99aae9aa3f89f7bfe667db2c5b767f21f
URL: https://github.com/llvm/llvm-project/commit/f8cb78e99aae9aa3f89f7bfe667db2c5b767f21f
DIFF: https://github.com/llvm/llvm-project/commit/f8cb78e99aae9aa3f89f7bfe667db2c5b767f21f.diff
LOG: [ELF] Don't define __rela_iplt_start for -pie/-shared
`clang -fuse-ld=lld -static-pie -fpie` produced executable
currently crashes and this patch makes it work.
See https://sourceware.org/bugzilla/show_bug.cgi?id=27164
and https://sourceware.org/pipermail/libc-alpha/2021-July/128810.html
While it seems unreasonable to keep csu/libc-start.c ARCH_APPLY_IREL unclear in
static-pie mode and have an unneeded diff -u =(ld.bfd --verbose) =(ld.bfd -pie
--verbose) difference, glibc folks don't want to fix their code.
I feel sad about that but this patch can remove an iffy condition for lld/ELF
as well: `needsInterpSection()`.
Added:
Modified:
lld/ELF/Writer.cpp
lld/test/ELF/gnu-ifunc-nonpreemptible.s
Removed:
################################################################################
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index e22568f53488b..f455d8575e2db 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1088,7 +1088,7 @@ void PhdrEntry::add(OutputSection *sec) {
// need these symbols, since IRELATIVE relocs are resolved through GOT
// and PLT. For details, see http://www.airs.com/blog/archives/403.
template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
- if (config->relocatable || needsInterpSection())
+ if (config->relocatable || config->isPic)
return;
// By default, __rela_iplt_{start,end} belong to a dummy section 0
diff --git a/lld/test/ELF/gnu-ifunc-nonpreemptible.s b/lld/test/ELF/gnu-ifunc-nonpreemptible.s
index 35400e74d802b..dcc4f5d8c7903 100644
--- a/lld/test/ELF/gnu-ifunc-nonpreemptible.s
+++ b/lld/test/ELF/gnu-ifunc-nonpreemptible.s
@@ -20,8 +20,8 @@
# RUN: ld.lld -shared %t.o -o %t2
# RUN: llvm-readelf -s %t2 | FileCheck %s --check-prefix=PIC
-# PIC: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_start
-# PIC-NEXT: 0 NOTYPE LOCAL HIDDEN [[#]] __rela_iplt_end
+# PIC: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_start
+# PIC-NEXT: 0 NOTYPE WEAK DEFAULT UND __rela_iplt_end
# DISASM: Disassembly of section .text:
# DISASM-EMPTY:
More information about the llvm-commits
mailing list