Skip to content

Commit

Permalink
Stop using SHF_GNU_RETAIN for some reflection sections
Browse files Browse the repository at this point in the history
To have consistent section flags between compiler emitted object files
and swiftrt.o.
  • Loading branch information
kateinoigakukun committed Feb 7, 2024
1 parent 0e410da commit 05e2fc1
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions stdlib/public/runtime/SwiftRT-ELF-WASM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,40 @@ static const void *__backtraceRef __attribute__((used))
// by the linker. Otherwise, we may end up with undefined symbol references as
// the linker table section was never constructed.
#if defined(__ELF__)
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"aR\"\n");
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"a\"\n");
# define DECLARE_EMPTY_RETAINED_METADATA_SECTION(name) __asm__("\t.section " #name ",\"aR\"\n");
#elif defined(__wasm__)
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"\",@\n");
# define DECLARE_EMPTY_RETAINED_METADATA_SECTION(name) DECLAREDECLARE_EMPTY_METADATA_SECTION(name)
#endif

#define DECLARE_SWIFT_SECTION(name) \
DECLARE_EMPTY_METADATA_SECTION(name) \
#define DECLARE_SWIFT_ENCAPSULATION_SYMBOLS(name) \
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __start_##name; \
__attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __stop_##name;

#define DECLARE_SWIFT_SECTION(name) \
DECLARE_EMPTY_METADATA_SECTION(name) \
DECLARE_SWIFT_ENCAPSULATION_SYMBOLS(name)

#define DECLARE_SWIFT_RETAINED_SECTION(name) \
DECLARE_EMPTY_RETAINED_METADATA_SECTION(name) \
DECLARE_SWIFT_ENCAPSULATION_SYMBOLS(name)

extern "C" {
DECLARE_SWIFT_SECTION(swift5_protocols)
DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
DECLARE_SWIFT_SECTION(swift5_type_metadata)
DECLARE_SWIFT_RETAINED_SECTION(swift5_protocols)
DECLARE_SWIFT_RETAINED_SECTION(swift5_protocol_conformances)
DECLARE_SWIFT_RETAINED_SECTION(swift5_type_metadata)

DECLARE_SWIFT_SECTION(swift5_typeref)
DECLARE_SWIFT_SECTION(swift5_reflstr)
DECLARE_SWIFT_SECTION(swift5_fieldmd)
DECLARE_SWIFT_SECTION(swift5_assocty)
DECLARE_SWIFT_SECTION(swift5_replace)
DECLARE_SWIFT_SECTION(swift5_replac2)
DECLARE_SWIFT_SECTION(swift5_builtin)
DECLARE_SWIFT_SECTION(swift5_capture)
DECLARE_SWIFT_SECTION(swift5_mpenum)
DECLARE_SWIFT_SECTION(swift5_accessible_functions)
DECLARE_SWIFT_RETAINED_SECTION(swift5_fieldmd)
DECLARE_SWIFT_RETAINED_SECTION(swift5_assocty)
DECLARE_SWIFT_RETAINED_SECTION(swift5_replace)
DECLARE_SWIFT_RETAINED_SECTION(swift5_replac2)
DECLARE_SWIFT_RETAINED_SECTION(swift5_builtin)
DECLARE_SWIFT_RETAINED_SECTION(swift5_capture)
DECLARE_SWIFT_RETAINED_SECTION(swift5_mpenum)
DECLARE_SWIFT_RETAINED_SECTION(swift5_accessible_functions)
DECLARE_SWIFT_SECTION(swift5_runtime_attributes)
}

Expand Down

0 comments on commit 05e2fc1

Please sign in to comment.