[Bug c++/64697] C++11 thread_local: relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for N::ptd'
wilson at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 26 22:03:11 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64697
Jim Wilson <wilson at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wilson at gcc dot gnu.org
--- Comment #22 from Jim Wilson <wilson at gcc dot gnu.org> ---
This looks like a binutils bug to me. A call to an undefined weak function
should never be executed, so it is OK for the linker to convert that call
instruction into anything convenient. There is no need for a relocation that
can reach an address of zero. We can convert the call instruction to call
itself, or the next instruction, or change it to a nop, what ever is
convenient, it doesn't really matter.
A number of binutils ports already have code to handle related problems. ARM
and RISC-V for sure. Probably others. It looks like this support is missing
from the x86_64 port. I'd suggest refiling this as a binutils bug. See for
instance
https://sourceware.org/bugzilla/show_bug.cgi?id=23244
for a RISC-V example of the same problem. But we need a new bug for the x86_64
problem. RISC-V has a register hard wired to zero, so I rewrite the call
instruction to use x0 as the base address. The arm port turns the call into a
nop.
More information about the Gcc-bugs
mailing list