@@ -28,29 +28,52 @@ using StaticInfixWitness = SWIFT_CC(swift) bool(OpaqueValue *, OpaqueValue *,
2828 const Metadata *,
2929 const WitnessTable *);
3030
31+ // Elf indirect symbol references.
3132#if defined(__ELF__)
3233#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOTPCREL + 1"
33- #elif defined(__MACH__)
34+ #endif
35+
36+ // MachO indirect symbol references.
37+ #if defined(__MACH__)
38+
39+ // 64 bit arm MachO
3440#if defined(__aarch64__)
3541#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOT - . + 1"
42+
43+ // 32 bit arm MachO
3644#elif defined(__arm__)
37- // Darwin doesn't support @GOT like syntax for 32 bit ARM.
45+ // MachO doesn't support @GOT like relocations for 32 bit arm.
46+ #define INDIRECT_RELREF_GOTPCREL (SYMBOL ) " L" SYMBOL " $non_lazy_ptr - . + 1"
47+ #endif
48+
49+ // 64 bit x86_64 MachO
50+ #if defined(__x86_64__)
51+ // The + 4 is required for all x86_64 MachO GOTPC relocations.
52+ #define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOTPCREL + 4 + 1"
53+
54+ // 32 bit x86 MachO
55+ #elif defined(__i386__)
56+ // MachO doesn't support @GOT like relocations for 32 bit x86.
3857#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) " L" SYMBOL " $non_lazy_ptr - . + 1"
39- #else
40- #define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOTPCREL + 5"
4158#endif
59+
4260#endif
4361
4462// ===----------------------------------------------------------------------===//
4563// Tuple Equatable Conformance
4664// ===----------------------------------------------------------------------===//
4765
48- // For 32 bit ARM (specifically armv7 and armv7s for iphoneos), emit non-lazy
49- // pointer stubs to indirectly reference. Darwin doesn't support @GOT syntax for
50- // ARM.
51- #if defined(__MACH__) && defined(__arm__) && !defined(__aarch64__)
66+ // For 32 bit ARM and i386 (specifically armv7, armv7s, and armv7k), emit
67+ // non-lazy pointer stubs to indirectly reference. Darwin doesn't support @GOT
68+ // syntax for those archs.
69+ #if defined(__MACH__) && \
70+ ((defined (__arm__) && !defined (__aarch64__)) || defined (__i386__))
5271__asm (
72+ #if defined(__arm__)
5373 " .section __DATA, __nl_symbol_ptr, non_lazy_symbol_pointers\n "
74+ #elif defined(__i386__)
75+ " .section __IMPORT, __pointers, non_lazy_symbol_pointers\n "
76+ #endif
5477 " .p2align 2\n "
5578 " L" EQUATABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
5679 " .indirect_symbol " EQUATABLE_DESCRIPTOR_SYMBOL " \n "
@@ -156,12 +179,17 @@ bool swift::_swift_tupleEquatable_equals(OpaqueValue *tuple1,
156179// Tuple Comparable Conformance
157180// ===----------------------------------------------------------------------===//
158181
159- // For 32 bit ARM (specifically armv7 and armv7s for iphoneos), emit non-lazy
160- // pointer stubs to indirectly reference. Darwin doesn't support @GOT syntax for
161- // ARM.
162- #if defined(__MACH__) && defined(__arm__) && !defined(__aarch64__)
182+ // For 32 bit ARM and i386 (specifically armv7, armv7s, and armv7k), emit
183+ // non-lazy pointer stubs to indirectly reference. Darwin doesn't support @GOT
184+ // syntax for those archs.
185+ #if defined(__MACH__) && \
186+ ((defined (__arm__) && !defined (__aarch64__)) || defined (__i386__))
163187__asm (
188+ #if defined(__arm__)
164189 " .section __DATA, __nl_symbol_ptr, non_lazy_symbol_pointers\n "
190+ #elif defined(__i386__)
191+ " .section __IMPORT, __pointers, non_lazy_symbol_pointers\n "
192+ #endif
165193 " .p2align 2\n "
166194 " L" COMPARABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
167195 " .indirect_symbol " COMPARABLE_DESCRIPTOR_SYMBOL " \n "
@@ -544,12 +572,17 @@ bool swift::_swift_tupleComparable_greaterThan(OpaqueValue *tuple1,
544572// Tuple Hashable Conformance
545573// ===----------------------------------------------------------------------===//
546574
547- // For 32 bit ARM (specifically armv7 and armv7s for iphoneos), emit non-lazy
548- // pointer stubs to indirectly reference. Darwin doesn't support @GOT syntax for
549- // ARM.
550- #if defined(__MACH__) && defined(__arm__) && !defined(__aarch64__)
575+ // For 32 bit ARM and i386 (specifically armv7, armv7s, and armv7k), emit
576+ // non-lazy pointer stubs to indirectly reference. Darwin doesn't support @GOT
577+ // syntax for those archs.
578+ #if defined(__MACH__) && \
579+ ((defined (__arm__) && !defined (__aarch64__)) || defined (__i386__))
551580__asm (
581+ #if defined(__arm__)
552582 " .section __DATA, __nl_symbol_ptr, non_lazy_symbol_pointers\n "
583+ #elif defined(__i386__)
584+ " .section __IMPORT, __pointers, non_lazy_symbol_pointers\n "
585+ #endif
553586 " .p2align 2\n "
554587 " L" HASHABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
555588 " .indirect_symbol " HASHABLE_DESCRIPTOR_SYMBOL " \n "
0 commit comments