[PATCH] ld: Allow R_X86_64_GOTPCREL for call *__tls_get_addr@GOTPCREL(%rip)
Jan Beulich
jbeulich@suse.com
Thu Mar 2 11:37:39 GMT 2023
On 05.01.2023 22:05, Fangrui Song via Binutils wrote:
> _Thread_local int a;
> int main() { return a; }
>
> % gcc -fno-plt -fpic a.c -fuse-ld=bfd -Wa,-mrelax-relocations=no
> /usr/bin/ld.bfd: /tmp/ccSSBgrg.o: TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against `a' at 0xd 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.
The discussion with H.J. looks to have died out, without a clear result.
May I suggest the following (also for the other, 32-bit patch): You
extend the description to address H.J.'s concerns verbally, and unless
he comes forward pointing actual flaws in here, I'd then intend to
approve the changes.
Jan
> PR ld/24784
> * bfd/elf64-x86-64.c (elf_x86_64_check_tls_transition): Allow
> R_X86_64_GOTPCREL.
> ---
> bfd/elf64-x86-64.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
> index 914f82d0151..095fe2e0fe6 100644
> --- a/bfd/elf64-x86-64.c
> +++ b/bfd/elf64-x86-64.c
> @@ -1241,7 +1241,7 @@ elf_x86_64_check_tls_transition (bfd *abfd,
> if (largepic)
> return r_type == R_X86_64_PLTOFF64;
> else if (indirect_call)
> - return r_type == R_X86_64_GOTPCRELX;
> + return (r_type == R_X86_64_GOTPCRELX || r_type == R_X86_64_GOTPCREL);
> else
> return (r_type == R_X86_64_PC32 || r_type == R_X86_64_PLT32);
> }
More information about the Binutils
mailing list