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.
Comment #1 by k.hara.pg — 2015-01-06T14:14:54Z
Comment #2 by code — 2015-01-06T22:34:40Z
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
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c9a383cb926580c22a9219619750bc801eb9b159 fix Issue 13939 - IASM shouldn't access global symbol with PIC code https://github.com/D-Programming-Language/dmd/commit/756cda4c5a73ac35c7f48faae20de73493d210a4 Merge pull request #4260 from 9rnsr/fix_iasm Issue 13938 & 13939 - Disallow non-trivial variable accesses in iasm
Comment #4 by github-bugzilla — 2015-02-18T03:42:00Z