Bug 19551 – corrupt ELF library when using pragma(crt_constructor)

Status
RESOLVED
Resolution
WORKSFORME
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-01-05T12:56:37Z
Last change time
2022-05-18T06:47:44Z
Keywords
backend
Assigned to
No Owner
Creator
Rainer Schuetze

Comments

Comment #0 by r.sagitario — 2019-01-05T12:56:37Z
building these 2 files to a library: ////////////////////////////////// module lib18456; __gshared int initVar; pragma(crt_constructor) 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".
Comment #1 by maxhaton — 2022-05-18T02:40:03Z
I can't reproduce this
Comment #2 by r.sagitario — 2022-05-18T06:47:44Z
I cannot reproduce it anymore, too. Might have been some intermediate version.