>> 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 rex64 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. Cheers, Rafael
On 22 May 2013, at 14:28, Rafael Espíndola <rafael.espindola at gmail.com> wrote:> I wouldn't be surprised if > these relocations are not implemented yet, but that should be all that > is needed to get tls working.That was, indeed, where this discussion started. Andrew's suggestion was to use the small code model, in the hope that this would fix some things. The lack of support for these relocations is what is stopping my code from working with MCJIT, and your removal of EH is stopping it working with the legacy JIT. David
On 22 May 2013 09:37, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> On 22 May 2013, at 14:28, Rafael Espíndola <rafael.espindola at gmail.com> wrote: > >> I wouldn't be surprised if >> these relocations are not implemented yet, but that should be all that >> is needed to get tls working. > > That was, indeed, where this discussion started. Andrew's suggestion was to use the small code model, in the hope that this would fix some things. The lack of support for these relocations is what is stopping my code from working with MCJIT, and your removal of EH is stopping it working with the legacy JIT.Well, these relocations are there because of the general dynamic tls model, so they would be present on all code models. Cheers, Rafael