@@ -49,6 +49,15 @@ enum _dyld_section_location_kind {
49
49
50
50
#endif
51
51
52
+ // Bring our own definition of _dyld_section_location constants in case we're
53
+ // using an older SDK that doesn't have them.
54
+ #define _dyld_section_location_text_swift5_protos 0
55
+ #define _dyld_section_location_text_swift5_proto 1
56
+ #define _dyld_section_location_text_swift5_types 2
57
+ #define _dyld_section_location_text_swift5_replace 3
58
+ #define _dyld_section_location_text_swift5_replace2 4
59
+ #define _dyld_section_location_text_swift5_ac_funcs 5
60
+
52
61
#if !OBJC_ADDLOADIMAGEFUNC2_DEFINED
53
62
// If we don't have objc_addLoadImageFunc2, fall back to objc_addLoadImageFunc.
54
63
// Use a #define so we don't have to conditionalize the calling code below.
@@ -79,8 +88,7 @@ using mach_header_platform = mach_header;
79
88
#endif
80
89
81
90
// Callback for objc_addLoadImageFunc that just takes a mach_header.
82
- template <const char *SEGMENT_NAME, const char *SECTION_NAME,
83
- enum _dyld_section_location_kind SECTION_KIND,
91
+ template <const char *SEGMENT_NAME, const char *SECTION_NAME, int SECTION_KIND,
84
92
void CONSUME_BLOCK (const void *baseAddress, const void *start,
85
93
uintptr_t size)>
86
94
void addImageCallback(const mach_header *mh) {
@@ -102,8 +110,7 @@ void addImageCallback(const mach_header *mh) {
102
110
103
111
// Callback for objc_addLoadImageFunc2 that takes a mach_header and dyld info.
104
112
#if OBJC_ADDLOADIMAGEFUNC2_DEFINED
105
- template <const char *SEGMENT_NAME, const char *SECTION_NAME,
106
- enum _dyld_section_location_kind SECTION_KIND,
113
+ template <const char *SEGMENT_NAME, const char *SECTION_NAME, int SECTION_KIND,
107
114
void CONSUME_BLOCK (const void *baseAddress, const void *start,
108
115
uintptr_t size)>
109
116
void addImageCallback(const mach_header *mh,
@@ -112,16 +119,17 @@ void addImageCallback(const mach_header *mh,
112
119
assert (mh->magic == MH_MAGIC_64 && " loaded non-64-bit image?!" );
113
120
#endif
114
121
115
- auto result = _dyld_lookup_section_info (mh, dyldInfo, SECTION_KIND);
122
+ auto result = _dyld_lookup_section_info (
123
+ mh, dyldInfo,
124
+ static_cast <enum _dyld_section_location_kind>(SECTION_KIND));
116
125
if (result.buffer )
117
126
CONSUME_BLOCK (mh, result.buffer , result.bufferSize );
118
127
}
119
128
#endif
120
129
121
130
// Callback for _dyld_register_func_for_add_image that takes a mach_header and a
122
131
// slide.
123
- template <const char *SEGMENT_NAME, const char *SECTION_NAME,
124
- enum _dyld_section_location_kind SECTION_KIND,
132
+ template <const char *SEGMENT_NAME, const char *SECTION_NAME, int SECTION_KIND,
125
133
void CONSUME_BLOCK (const void *baseAddress, const void *start,
126
134
uintptr_t size)>
127
135
void addImageCallback(const mach_header *mh, intptr_t vmaddr_slide) {
@@ -132,11 +140,10 @@ void addImageCallback(const mach_header *mh, intptr_t vmaddr_slide) {
132
140
133
141
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
134
142
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
135
- enum _dyld_section_location_kind SECTION_KIND,
136
- enum _dyld_section_location_kind SECTION_KIND2,
137
- void CONSUME_BLOCK (const void *baseAddress,
138
- const void *start, uintptr_t size,
139
- const void *start2, uintptr_t size2)>
143
+ int SECTION_KIND, int SECTION_KIND2,
144
+ void CONSUME_BLOCK (const void *baseAddress, const void *start,
145
+ uintptr_t size, const void *start2,
146
+ uintptr_t size2)>
140
147
void addImageCallback2Sections(const mach_header *mh) {
141
148
#if __POINTER_WIDTH__ == 64
142
149
assert (mh->magic == MH_MAGIC_64 && " loaded non-64-bit image?!" );
@@ -168,23 +175,26 @@ void addImageCallback2Sections(const mach_header *mh) {
168
175
#if OBJC_ADDLOADIMAGEFUNC2_DEFINED
169
176
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
170
177
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
171
- enum _dyld_section_location_kind SECTION_KIND,
172
- enum _dyld_section_location_kind SECTION_KIND2,
173
- void CONSUME_BLOCK (const void *baseAddress,
174
- const void *start, uintptr_t size,
175
- const void *start2, uintptr_t size2)>
178
+ int SECTION_KIND, int SECTION_KIND2,
179
+ void CONSUME_BLOCK (const void *baseAddress, const void *start,
180
+ uintptr_t size, const void *start2,
181
+ uintptr_t size2)>
176
182
void addImageCallback2Sections(const mach_header *mh,
177
183
struct _dyld_section_location_info_s *dyldInfo) {
178
184
#if __POINTER_WIDTH__ == 64
179
185
assert (mh->magic == MH_MAGIC_64 && " loaded non-64-bit image?!" );
180
186
#endif
181
187
182
188
// Look for a section.
183
- auto result = _dyld_lookup_section_info (mh, dyldInfo, SECTION_KIND);
189
+ auto result = _dyld_lookup_section_info (
190
+ mh, dyldInfo,
191
+ static_cast <enum _dyld_section_location_kind>(SECTION_KIND));
184
192
if (!result.buffer )
185
193
return ;
186
194
187
- auto result2 = _dyld_lookup_section_info (mh, dyldInfo, SECTION_KIND2);
195
+ auto result2 = _dyld_lookup_section_info (
196
+ mh, dyldInfo,
197
+ static_cast <enum _dyld_section_location_kind>(SECTION_KIND2));
188
198
// No NULL check here, we allow this one not to be present. dyld gives us
189
199
// a NULL pointer and 0 size when the section isn't in the dylib so we don't
190
200
// need to zero anything out.
@@ -198,8 +208,7 @@ void addImageCallback2Sections(const mach_header *mh,
198
208
// slide.
199
209
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
200
210
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
201
- enum _dyld_section_location_kind SECTION_KIND,
202
- enum _dyld_section_location_kind SECTION_KIND2,
211
+ int SECTION_KIND, int SECTION_KIND2,
203
212
void CONSUME_BLOCK (const void *baseAddress, const void *start,
204
213
uintptr_t size, const void *start2,
205
214
uintptr_t size2)>
0 commit comments