On Wed, Aug 14, 2013 at 12:03 AM, Uros Bizjak <ubiz...@gmail.com> wrote: > On Tue, Aug 13, 2013 at 9:42 PM, Jakub Jelinek <ja...@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.