This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] -mcmodel=large -fpic TLS GD and LD support gcc + binutils (PR target/58067)
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, Richard Henderson <rth at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Binutils <binutils at sourceware dot org>, Alexandre Oliva <aoliva at redhat dot com>
- Date: Mon, 19 Aug 2013 10:38:53 -0700
- Subject: Re: [PATCH] -mcmodel=large -fpic TLS GD and LD support gcc + binutils (PR target/58067)
- References: <20130813194235 dot GJ1814 at tucnak dot redhat dot com> <CAFULd4Ye9J-EnrE4cD8KtLqdXsE-a-oMAW+jOfFVzY0bK6=JhA at mail dot gmail dot com>
On Wed, Aug 14, 2013 at 12:03 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> 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
>
I agree. We need to document the TLS code sequences
for PIC/non-PIC medium/large models first.
--
H.J.