Hi Kai, On Tue, Feb 19, 2013 at 7:27 PM, Kai Tietz <[email protected]> wrote: > - (ULONG_PTR) &_tls_start+1, (ULONG_PTR) &_tls_end, > + (ULONG_PTR) &_tls_start, (ULONG_PTR) &_tls_end, > > looks to me wrong due we always have one pointer-size allocated in TLS. > > shouldn't be the required fix as the following here? > > - (ULONG_PTR) &_tls_start+1, (ULONG_PTR) &_tls_end, > + (ULONG_PTR) (&_tls_start+1), (ULONG_PTR) &_tls_end,
I'm afraid I can only repeat what I already wrote before: _tls_start must point to the start of the TLS section. To illustrate this, consider the following small program that prints (or rather, should print) "cafebabe, deadbeef", with the hex values read from TLS variables: --- .section .text.startup,"x" .globl _main .def _main; .scl 2; .type 32; .endef _main: subl $12, %esp movl __tls_index, %eax movl %fs:44, %ecx movl (%ecx,%eax,4), %ecx movl _tlsVar1@SECREL32(%ecx), %eax movl _tlsVar2@SECREL32(%ecx), %ecx movl %ecx, 8(%esp) movl %eax, 4(%esp) movl $_.str, (%esp) call _printf xorl %eax, %eax addl $12, %esp ret .section .tls$,"w" .globl _tlsVar1 .align 4 _tlsVar1: .long 0xcafebabe .globl _tlsVar2 .align 4 _tlsVar2: .long 0xdeadbeef .section .rdata,"dr" _.str: .asciz "%x, %x\n" --- Note how in the Windows TLS model, the base address is first computed based on __tls_index and %fs:44, and then the offset of the respective variable from the beginning of the section it is in (.tls) is added. Now, if the start address entry of the TLS info struct does not point to the beginning of the section, it is obvious that the offsets obtained via the SECREL relecation will be off, as Windows will use the given range to initialize the TLS area for new threads. With my patch, the above program produces the correct output. Without it, it will rather print "efcafeba, deadbe" (or similar, didn't check against an old libmingw32.a). David ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
