Skip to content

Commit b755724

Browse files
committed
[Runtime] Tidy up section declarations slightly.
This also calls out the reflection sections, even though we don't actually need to do anything special for them (as it turns out). rdar://123504095
1 parent 3c029eb commit b755724

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

stdlib/public/runtime/SwiftRT-ELF-WASM.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,43 @@ static const void *__backtraceRef __attribute__((used))
3636
// by the linker. Otherwise, we may end up with undefined symbol references as
3737
// the linker table section was never constructed.
3838
#if defined(__ELF__)
39-
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"a\"\n");
39+
# define DECLARE_EMPTY_METADATA_SECTION(name,attrs) __asm__("\t.section " #name ",\"" attrs "\"\n");
4040
#elif defined(__wasm__)
41-
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"R\",@\n");
41+
# define DECLARE_EMPTY_METADATA_SECTION(name,attrs) __asm__("\t.section " #name ",\"R\",@\n");
4242
#endif
4343

44-
#define DECLARE_SWIFT_SECTION(name) \
45-
DECLARE_EMPTY_METADATA_SECTION(name) \
46-
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __start_##name; \
47-
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __stop_##name;
44+
#define BOUNDS_VISIBILITY __attribute__((__visibility__("hidden"),__aligned__(1)))
45+
#define DECLARE_BOUNDS(name) \
46+
BOUNDS_VISIBILITY extern const char __start_##name; \
47+
BOUNDS_VISIBILITY extern const char __stop_##name;
48+
49+
#define DECLARE_SWIFT_SECTION(name) \
50+
DECLARE_EMPTY_METADATA_SECTION(name,"aR") \
51+
DECLARE_BOUNDS(name)
52+
53+
// These may or may not be present, depending on compiler switches; it's
54+
// worth calling them out as a result.
55+
#define DECLARE_SWIFT_REFLECTION_SECTION(name) \
56+
DECLARE_SWIFT_SECTION(name)
4857

4958
extern "C" {
5059
DECLARE_SWIFT_SECTION(swift5_protocols)
5160
DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
5261
DECLARE_SWIFT_SECTION(swift5_type_metadata)
5362

54-
DECLARE_SWIFT_SECTION(swift5_typeref)
55-
DECLARE_SWIFT_SECTION(swift5_reflstr)
56-
DECLARE_SWIFT_SECTION(swift5_fieldmd)
57-
DECLARE_SWIFT_SECTION(swift5_assocty)
63+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_fieldmd)
64+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_builtin)
65+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_assocty)
66+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_capture)
67+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_reflstr)
68+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_typeref)
69+
DECLARE_SWIFT_REFLECTION_SECTION(swift5_mpenum)
70+
5871
DECLARE_SWIFT_SECTION(swift5_replace)
5972
DECLARE_SWIFT_SECTION(swift5_replac2)
60-
DECLARE_SWIFT_SECTION(swift5_builtin)
61-
DECLARE_SWIFT_SECTION(swift5_capture)
62-
DECLARE_SWIFT_SECTION(swift5_mpenum)
6373
DECLARE_SWIFT_SECTION(swift5_accessible_functions)
6474
DECLARE_SWIFT_SECTION(swift5_runtime_attributes)
75+
6576
DECLARE_SWIFT_SECTION(swift5_tests)
6677
}
6778

0 commit comments

Comments
 (0)