Skip to content

Commit 94ffb34

Browse files
committed
Mark swift sections as 1 byte aligned
The C compiler on some platforms (such as s390x) assumes that the data pointed to by symbols meets certain alignment requirements. The swift sections do not necessarily meet these alignment requirements so this change adds alignment attributes to them to force the compiler to emit the instruction sequences and relocations required to address unaligned data. This fixes a 'R_390_PC32DBL target misaligned' warning issued by gold on s390x.
1 parent 4ddeba1 commit 94ffb34

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/public/runtime/SwiftRT-ELF.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
// by the linker. Otherwise, we may end up with undefined symbol references as
1919
// the linker table section was never constructed.
2020

21-
#define DECLARE_SWIFT_SECTION(name) \
22-
__asm__("\t.section " #name ",\"a\"\n"); \
23-
__attribute__((__visibility__("hidden"))) extern const char __start_##name; \
24-
__attribute__((__visibility__("hidden"))) extern const char __stop_##name;
21+
#define DECLARE_SWIFT_SECTION(name) \
22+
__asm__("\t.section " #name ",\"a\"\n"); \
23+
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __start_##name; \
24+
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __stop_##name;
2525

2626
extern "C" {
2727
DECLARE_SWIFT_SECTION(swift5_protocols)

0 commit comments

Comments
 (0)