From: Daniel Bertalan Date: Thu, 10 Nov 2022 21:42:19 +0000 (+0100) Subject: [lld-macho] Set 4-byte alignment for `__init_offsets` X-Git-Tag: upstream/17.0.6~27987 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=948fc66f5e86450e602a1d48025f76b13efd5bd2;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index c1da641..267f97a 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -1899,6 +1899,7 @@ void ObjCImageInfoSection::writeTo(uint8_t *buf) const { InitOffsetsSection::InitOffsetsSection() : SyntheticSection(segment_names::text, section_names::initOffsets) { flags = S_INIT_FUNC_OFFSETS; + align = 4; // This section contains 32-bit integers. } uint64_t InitOffsetsSection::getSize() const { diff --git a/lld/test/MachO/init-offsets.s b/lld/test/MachO/init-offsets.s index 9a27033..844951a 100644 --- a/lld/test/MachO/init-offsets.s +++ b/lld/test/MachO/init-offsets.s @@ -27,7 +27,7 @@ # FLAGS-NEXT: addr # FLAGS-NEXT: size 0x0000000000000010 # FLAGS-NEXT: offset -# FLAGS-NEXT: align +# FLAGS-NEXT: align 2^2 (4) # FLAGS-NEXT: reloff 0 # FLAGS-NEXT: nreloc 0 # FLAGS-NEXT: type S_INIT_FUNC_OFFSETS