D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14311 - Win32 COFF: bad symbols/relocation entries for global data accesses
Summary: Win32 COFF: bad symbols/relocation entries for global data accesses
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 major
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2015-03-20 07:07 UTC by Rainer Schuetze
Modified: 2015-06-17 21:02 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2015-03-20 07:07:24 UTC
Compile this code for Win64 with "dmd -m32mscoff test.d":

module test;

private __gshared int transform;

shared static this()
{
    transform = 3;
}

and check the object file output with "dumpbin /disasm /all test.obj":

_D4test18_sharedStaticCtor1FZv:
  00000000: C7 05 00 00 00 00  mov         dword ptr [__TMP0],3
            03 00 00 00
  0000000A: C3                 ret

i.e. there is a temporary symbol created for the variable access instead of the actual symbol itself, as the dump for the Win64 build shows:

_D4test18_sharedStaticCtor1FZv:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: C7 05 00 00 00 00  mov         dword ptr [_D4test9transformi],3
                    03 00 00 00
  000000000000000E: 5D                 pop         rbp
  000000000000000F: C3                 ret

This causes bad relocation entries to be built into the executable and causing failures for the phobos unit tests.
Comment 1 Rainer Schuetze 2015-03-20 07:41:48 UTC
https://github.com/D-Programming-Language/dmd/pull/4504
Comment 2 github-bugzilla 2015-03-21 09:46:53 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6b426b369ec0a7e040412ecd75a381e87d051701
Merge pull request #4504 from rainers/issue_14311

fix Issue 14311 - Win32 COFF: don't loose symbol information for global data accesses
Comment 3 github-bugzilla 2015-06-17 21:02:34 UTC
Commit pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6b426b369ec0a7e040412ecd75a381e87d051701
Merge pull request #4504 from rainers/issue_14311