[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/24784] elf_x86_64_check_tls_transition should allow R_X86_64_GOT
From: |
cvs-commit at gcc dot gnu.org |
Subject: |
[Bug ld/24784] elf_x86_64_check_tls_transition should allow R_X86_64_GOTPCREL (-fno-plt) |
Date: |
Fri, 10 Mar 2023 19:55:12 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24784
--- Comment #12 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot
gnu.org> ---
The master branch has been updated by Fangrui Song <maskray@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2cef48423031d23d319692ceced5ad0110625f69
commit 2cef48423031d23d319692ceced5ad0110625f69
Author: Fangrui Song <maskray@google.com>
Date: Fri Mar 10 11:55:09 2023 -0800
ld: Allow R_386_GOT32 for call *__tls_get_addr@GOT(%reg)
Similar to d58854b6dd88e05dbf2a5d1c32c5acb7bd6ea274 for x86_64.
_Thread_local int a;
int main() { return a; }
% gcc -m32 -fno-plt -fpic a.c -fuse-ld=bfd -Wa,-mrelax-relocations=no
/usr/bin/ld.bfd: /tmp/ccR8Yexy.o: TLS transition from R_386_TLS_GD to
R_386_TLS_IE_32 against `a' at 0x15 in section `.text' failed
/usr/bin/ld.bfd: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
This commit fixes the issue.
There is an argument that the -fno-plt TLS sequence was added after
R_386_GOT32X was required for call *func@GOT(%ebx), so R_386_GOT32 was
intended to be unsupported.
Unfortunately this standpoint has caused interop difficulty: some
projects specify -mrelax-relocations=no to build relocatable object
files compatible with older linkers (e.g.
https://github.com/IHaskell/IHaskell/issues/636) or do so by accident
(e.g. https://github.com/rust-lang/rust/pull/106511 not addressed as of
today). Many uses have not been cleaned up in practice, and compiling
with -fno-plt will lead to the `TLS transition from R_386_TLS_GD ...`
error which is hard to reason about.
It seems easier to apply this simple change to prevent the footgun.
PR ld/24784
* bfd/elf32-i386.c (elf_i386_check_tls_transition): Allow R_386_GOT32.
--
You are receiving this mail because:
You are on the CC list for the bug.