Skip to content

Commit d845e7b

Browse files
committed
runtime: force unaligned start/stop markers
The sections to which the start/stop symbols are being applied do not guarantee pointer alignment. In particular, the field metadata is aligned to a 4-byte boundary, which is less then the pointer alignment of `uintptr_t`. This results in extra padding in the data which is going to cause the iteration to run off the end. A similar byte alignment is forced for the markers in the ELF case as well. This fixes one of the reflection tests on Windows where we were attempting to decode the padding as an entry.
1 parent f39defa commit d845e7b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/runtime/SwiftRT-COFF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
#define DECLARE_SWIFT_SECTION(name) \
2828
PRAGMA(section("." #name "$A", long, read)) \
2929
__declspec(allocate("." #name "$A")) \
30+
__declspec(align(1)) \
3031
static uintptr_t __start_##name = 0; \
3132
\
3233
PRAGMA(section("." #name "$C", long, read)) \
3334
__declspec(allocate("." #name "$C")) \
35+
__declspec(align(1)) \
3436
static uintptr_t __stop_##name = 0;
3537

3638
extern "C" {

0 commit comments

Comments
 (0)