This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] -mcmodel=large -fpic TLS GD and LD support gcc + binutils (PR target/58067)


On Tue, Aug 13, 2013 at 9:42 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> We right now ICE with -mcmodel=large -fpic on x86_64 on TLS GD and LD
> sequences, because obviously we can't call __tls_get_addr@plt there from code
> potentially more than 2GB away from the PLT slot.
>
> The attached patches add support for that in gcc and also teaches linker
> about those, because otherwise the linker will fail if you try to link such
> -mcmodel=large -fpic code into binaries or PIEs.
>
> To make transitions possible, we emit always
> leaq foo@tlsgd(%rip), %rdi
> movabsq $__tls_get_addr@pltoff, %rax
> addq $rbx, %rax
> call *%rax
> resp.
> leaq foo@tlsld(%rip), %rdi
> movabsq $__tls_get_addr@pltoff, %rax
> addq $rbx, %rax
> call *%rax
> sequences (22 bytes, 6 bytes longer than what we do for TLSGD for normal
> libraries).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, attached is also the
> sources I've used to test all the 3 different transitions.
>
> Ok for trunk and 4.8 branch (and binutils trunk)?

The implementation for x86 is technically OK, but I wonder if these
sequences should be documented in some authoritative document about
TLS relocations. The "ELF Handling For Thread-Local Storage" document
[1] doesn't mention various code models fo x86_64, so I was not able
to cross-check the implementaton vs. documentation.

[1] http://www.akkadia.org/drepper/tls.pdf

Thanks,
Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]