Skip to content

Commit 948fc66

Browse files
committed
[lld-macho] Set 4-byte alignment for __init_offsets
dyld refuses to run initializers if this section is unaligned. Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1383240 Differential Revision: https://reviews.llvm.org/D137803
1 parent ccd1a5b commit 948fc66

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lld/MachO/SyntheticSections.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@ void ObjCImageInfoSection::writeTo(uint8_t *buf) const {
18991899
InitOffsetsSection::InitOffsetsSection()
19001900
: SyntheticSection(segment_names::text, section_names::initOffsets) {
19011901
flags = S_INIT_FUNC_OFFSETS;
1902+
align = 4; // This section contains 32-bit integers.
19021903
}
19031904

19041905
uint64_t InitOffsetsSection::getSize() const {

lld/test/MachO/init-offsets.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# FLAGS-NEXT: addr
2828
# FLAGS-NEXT: size 0x0000000000000010
2929
# FLAGS-NEXT: offset
30-
# FLAGS-NEXT: align
30+
# FLAGS-NEXT: align 2^2 (4)
3131
# FLAGS-NEXT: reloff 0
3232
# FLAGS-NEXT: nreloc 0
3333
# FLAGS-NEXT: type S_INIT_FUNC_OFFSETS

0 commit comments

Comments
 (0)