[Issue 19551] New: corrupt ELF library when using pragma(crt_constructor)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 5 12:56:37 UTC 2019


          Issue ID: 19551
           Summary: corrupt ELF library when using pragma(crt_constructor)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

building these 2 files to a library:

module lib18456;
__gshared int initVar;

extern(C) void mir_cpuid_crt_init()
    initVar = 42;

module test18456b;

class ManualGC {
    void enable() {}
    void disable() {}

with "dmd -m64 -oftest.a -lib test18456b.d test18456.d"

produces a corrupt library that when linked with

import lib18456;

void main()
    assert(initVar == 42);

via via "dmd -m64 test18456.d test.a" produces:

/usr/bin/ld: error: test.a(lib18456.o): size of section .ctors is not multiple
of address size
/usr/bin/ld: final link failed: Bad value

As the root corruption is not limited to use of pragma(crt_constructor), but
just goes unnoticed otherwise, I've raised severity to "critical".


More information about the Digitalmars-d-bugs mailing list