Bug 13939 – IASM shouldn't access global symbol with PIC code
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-05T20:00:00Z
Last change time
2015-02-18T03:42:00Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2015-01-05T20:00:49Z
cat > bug.d << CODE
void test1()
{
__gshared int val;
asm
{
mov EAX, val;
}
}
CODE
dmd -c -fPIC bug
It should be an error to access a global variable in IASM when compiling PIC code.
Like for TLS access to global PIC variables requires a particular instruction sequence and relocation.
Particularly for i686 you need to add the GOT offset (there currently no way to get that in IASM though).
BUT on amd64 it basically works fine because the compiler rewrites.
mov RAX, val;
to
mov RAX, val@RIP;
and also emits the correct relocation.
It will already fail for
movdqa XMM1, val;
see bug 9378.
Comment #3 by github-bugzilla — 2015-01-11T01:21:48Z