TLS on amd64

Daniel Müller Daniel.Mueller at mailbox.tu-dresden.de
Wed Jul 13 22:10:15 CEST 2011


Hello,
I want to use the __thread keyword gcc provides. I was told this was
recently adjusted to work (at least in the private repository which I am
using). It appears to be working when building for IA32 but when I
compile the same program for amd64 I get a page fault when running it
(it is a simple program just incrementing a __thread declared int).

It faults at 10010f4 (the first access of the variable).

00000000010010f0 <main>:
 10010f0:    48 83 ec 08              sub    rsp,0x8
 10010f4:    64 c7 04 25 fc ff ff     mov    DWORD PTR
fs:0xfffffffffffffffc,0x0
 10010fb:    ff 00 00 00 00
 1001100:    bf 60 48 01 01           mov    edi,0x1014860
 1001105:    e8 36 88 00 00           call   1009940 <puts>
 100110a:    64 83 04 25 fc ff ff     add    DWORD PTR
fs:0xfffffffffffffffc,0x1
 1001111:    ff 01
 1001113:    bf 01 00 00 00           mov    edi,0x1
 1001118:    e8 d3 71 00 00           call   10082f0 <sleep>
 100111d:    eb e1                    jmp    1001100 <main+0x10>
 100111f:    90                       nop

Is TLS for amd64 supposed to work? Any idea on the problem?

Greetings,
Daniel




More information about the l4-hackers mailing list