diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2023-03-07 11:42:20 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-03-08 01:24:58 -0500 |
commit | 4158722a6cff5d19e228356c525946b6c4b83396 (patch) | |
tree | 0bab715702184f609386d839ac347606edff2223 /rts | |
parent | 606793d424b08971f1eea4f1fae84b89297e1e63 (diff) | |
download | haskell-4158722a6cff5d19e228356c525946b6c4b83396.tar.gz |
linker: fix linking with aligned sections (#23066)
Take section alignment into account instead of assuming 16 bytes (which
is wrong when the section requires 32 bytes, cf #23066).
Diffstat (limited to 'rts')
-rw-r--r-- | rts/linker/Elf.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c index 3595a4c3d4..040107c7f1 100644 --- a/rts/linker/Elf.c +++ b/rts/linker/Elf.c @@ -872,12 +872,14 @@ ocGetNames_ELF ( ObjectCode* oc ) else if (!oc->imageMapped || size < getPageSize() / 3) { bool executable = kind == SECTIONKIND_CODE_OR_RODATA; m32_allocator *allocator = executable ? oc->rx_m32 : oc->rw_m32; - // align on 16 bytes. The reason being that llvm will emit see - // paddq statements for x86_64 under optimisation and load from - // RODATA sections. Specifically .rodata.cst16. However we don't - // handle the cst part in any way what so ever, so 16 seems - // better than 8. - start = m32_alloc(allocator, size, 16); + // Correctly align the section. This is particularly important for + // the alignment of .rodata.cstNN sections. + // + // llvm will emit see paddq statements for x86_64 under + // optimisation and load from RODATA sections, specifically + // .rodata.cst16. Also we may encounter .rodata.cst32 sections + // in objects using AVX instructions (see #23066). + start = m32_alloc(allocator, size, align); if (start == NULL) goto fail; memcpy(start, oc->image + offset, size); alloc = SECTION_M32; |