Notes |
|
(0000061)
|
Matze
|
2009-03-03 21:16
|
|
so what's the correct solution, disallowing thread local storage on mingw target? |
|
|
(0000066)
|
moritz
|
2009-03-04 12:26
|
|
Looking at how Visual C compiles thread.c it uses a special .tls PE section:
PUBLIC _tls_i
PUBLIC _tls_j
_TLS SEGMENT
_tls_i DD 0aH DUP (?)
_tls_j DD 05H
_TLS ENDS
PUBLIC _test
EXTRN __tls_array:DWORD
EXTRN __tls_index:DWORD
[...]
; 9 : tls_j = i;
mov eax, DWORD PTR __tls_index
mov ecx, DWORD PTR fs:__tls_array
mov edx, DWORD PTR [ecx+eax*4]
mov eax, DWORD PTR _i$[ebp]
mov DWORD PTR _tls_j[edx], eax
More info on this can be found at: http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx [^]
According to http://sourceware.org/ml/binutils/2003-10/msg00369.html [^] and http://gcc.gnu.org/ml/gcc/2006-06/msg00324.html [^] binutils already have some support for the .tls table ("Fortunately, the linker already supports setting the TLS directory entry in the PE header if a symbol named "__tls_used" exists.").
Sadly I didn't find a proper example on how an according .s file should look like. Trying
[...]
.section .tls
.globl __tls_used
.long 2
.globl _tls_i
.p2align 2
_tls_i:
.space 40
.globl _tls_j
.p2align 2
_tls_j:
.long 0x00000005
causes an segmentation fault in ld... |
|
|
(0000067)
|
moritz
|
2009-03-04 17:11
|
|
|
|
(0000288)
|
travm1
|
2017-04-07 05:49
|
|
|
|
(0000293)
|
waldgrasgeniesser
|
2017-05-08 16:14
|
|
I don't care that you broke your elbow. |
|