www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14311] New: Win32 COFF: bad symbols/relocation entries for

https://issues.dlang.org/show_bug.cgi?id=14311

          Issue ID: 14311
           Summary: Win32 COFF: bad symbols/relocation entries for global
                    data accesses
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

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.

--
Mar 20 2015