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