Alignment of symbol is not kept during linking
Yuxuan Shui
yshuiv7 at gmail.com
Thu Aug 9 13:30:38 UTC 2018
I'm trying to build LDC with dmd and Musl, but the result ldc
will always crash. I track that down to an unalignment SIMD
access to a global variable. Apparently C++ compiler thinks the
variable should be aligned to 16 bytes, but it's only aligned to
8 bytes.
After some more digging, I find out dmd does try to do the right
thing here. In the .o file, the offending symbol is indeed
aligned to 16 bytes. But, after linking, that symbol got bumped 8
bytes for some reason.
I searched around, and there seems to be no way to specify
alignment on symbol, so I don't think the linker is in the wrong
here.
C compilers would not put variables like that in .data, instead
they use SHN_COMMON, and specify alignment there. LDC will just
put every symbol into their own section, which also supports
alignment. dmd should probably do the same.
More information about the Digitalmars-d
mailing list