New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__rela_iplt_{start,end} get bogus section index if .rela.iplt section is discarded #35982
Comments
We've been investigating an issue with lld 6.0 in upcoming FreeBSD 12.0 which turns out to be this. |
From the FreeBSD PR, ld.bfd and gold pick different arbitrary sections for Ndx for these symbols: Linking with gold 1.15 (binutils 2.30): nuc% readelf -s a.out | grep iplt [ 8] .tdata PROGBITS 000000000048b070 0008a070 with ld.bfd 2.30 nuc% readelf -s a.out | grep iplt [ 1] .note.tag NOTE 0000000000400190 00000190 |
This is tricky. I have tried several approaches:
// freebsd/src/lib/csu/common/ignore_init.c #include "reloc.c" static void
} // glibc/csu/libc-start.c ifdef IREL
endif} I've seen a weird glibc R_X86_64_GOTPCRELX relocation error. In lld/ELF/Writer.cpp finalizeSections, there is some nuance when the following processes are reordered:
This requires a change in llvm-readobj as otherwise it would complain .rela.plt is not in any segment --- c/tools/llvm-readobj/ELFDumper.cpp
After that, Expected Passes : 1113 This place also needs patching:
|
The first option (leaving them undefined in the absence of ifuncs) is my preference. |
Maybe we can scan all symbols to make sure that there is at least one ifunc symbol before adding _rela_iplt{start,end} symbols. |
Fixed by https://reviews.llvm.org/D56623 |
Extended Description
For static linking, we synthesize __rela_iplt_start and __rela_iplt_end symbols which point to the beginning and ending of .rela.iplt. If .rela.iplt is discarded after that, then the symbols get bogus section index 0xffff. If that happens, no one really uses the symbols, so the symbols' section value doesn't matter, but it should at least be a sane value (0xffff is a reserved value).
The text was updated successfully, but these errors were encountered: