@@ -28,29 +28,52 @@ using StaticInfixWitness = SWIFT_CC(swift) bool(OpaqueValue *, OpaqueValue *,
28
28
const Metadata *,
29
29
const WitnessTable *);
30
30
31
+ // Elf indirect symbol references.
31
32
#if defined(__ELF__)
32
33
#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
34
40
#if defined(__aarch64__)
35
41
#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOT - . + 1"
42
+
43
+ // 32 bit arm MachO
36
44
#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.
38
57
#define INDIRECT_RELREF_GOTPCREL (SYMBOL ) " L" SYMBOL " $non_lazy_ptr - . + 1"
39
- #else
40
- #define INDIRECT_RELREF_GOTPCREL (SYMBOL ) SYMBOL " @GOTPCREL + 5"
41
58
#endif
59
+
42
60
#endif
43
61
44
62
// ===----------------------------------------------------------------------===//
45
63
// Tuple Equatable Conformance
46
64
// ===----------------------------------------------------------------------===//
47
65
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__))
52
71
__asm (
72
+ #if defined(__arm__)
53
73
" .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
54
77
" .p2align 2\n "
55
78
" L" EQUATABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
56
79
" .indirect_symbol " EQUATABLE_DESCRIPTOR_SYMBOL " \n "
@@ -156,12 +179,17 @@ bool swift::_swift_tupleEquatable_equals(OpaqueValue *tuple1,
156
179
// Tuple Comparable Conformance
157
180
// ===----------------------------------------------------------------------===//
158
181
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__))
163
187
__asm (
188
+ #if defined(__arm__)
164
189
" .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
165
193
" .p2align 2\n "
166
194
" L" COMPARABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
167
195
" .indirect_symbol " COMPARABLE_DESCRIPTOR_SYMBOL " \n "
@@ -544,12 +572,17 @@ bool swift::_swift_tupleComparable_greaterThan(OpaqueValue *tuple1,
544
572
// Tuple Hashable Conformance
545
573
// ===----------------------------------------------------------------------===//
546
574
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__))
551
580
__asm (
581
+ #if defined(__arm__)
552
582
" .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
553
586
" .p2align 2\n "
554
587
" L" HASHABLE_DESCRIPTOR_SYMBOL " $non_lazy_ptr:\n "
555
588
" .indirect_symbol " HASHABLE_DESCRIPTOR_SYMBOL " \n "
0 commit comments