Bug 13938 – IASM shouldn't be able to access TLS variables
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-05T19:58:00Z
Last change time
2017-07-18T13:47:25Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2015-01-05T19:58:28Z
cat > bug.d << CODE
void test1()
{
static int val;
asm
{
mov EAX, val;
}
}
CODE
dmd -c bug
This should print an error because the TLS variable can't be accessed like that.
It's fairly tricky, we would need to ensure that the correct code sequence is used. That's not really trackable and many can't be correctly written in D's IASM. So indeed it would be better to disallow them.
Comment #3 by code — 2015-01-06T22:37:53Z
For example this is the sequence to write to a TLS variable in X86 code (non-PIC), the one for X64 doesn't work, because dmd's IASM doesn't support RIP relative addressing.
size_t a;
void main()
{
asm
{
mov EAX, GS:[0x00];
mov ECX, a;
mov [EAX+1*ECX], 3;
}
}
Comment #4 by github-bugzilla — 2015-01-11T01:21:46Z