[LLVMdev] TLS with MCJIT (an experimental patch)

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed May 22 06:28:46 PDT 2013

>> So, the JIT is analogous to dlopen, so it should be using general
>> dynamic and local dynamic models. It is only the initial exec and
>> local exec that require the dynamic linker to allocate memory at
>> startup.
> The dynamic linker will have allocated the memory because the TLS variable in question is provided by libc.  It is already allocated before the JIT'd code runs.  The JIT'd code just needs to refer to it.

OK. Are we generating generic dynamic code to do so? It will look like

.byte 0x66
leaq x at tlsgd(%rip),%rdi    ; R_X86_64_TLSGD to symbol x (MCJIT has to
create a GOT entry)
.word 0x6666
call __tls get_addr at plt      ; R_X86_64_PLT32 to __tls_get_addr (MCJIT
has to create a GOT and a PLT entry)

This should work from any place in memory. I wouldn't be surprised if
these relocations are not implemented yet, but that should be all that
is needed to get tls working.


More information about the llvm-dev mailing list