33
33
#if __has_include(<objc/objc-internal.h>) && __has_include(<mach-o/dyld_priv.h>)
34
34
#include < mach-o/dyld_priv.h>
35
35
#include < objc/objc-internal.h>
36
- #else
37
-
38
- // Bring our own definition of enum _dyld_section_location_kind and some of its
39
- // values. They'll be unused when we can't include dyld_priv.h, but the code
40
- // needs them in order to compile.
41
- enum _dyld_section_location_kind {
42
- _dyld_section_location_text_swift5_protos,
43
- _dyld_section_location_text_swift5_proto,
44
- _dyld_section_location_text_swift5_types,
45
- _dyld_section_location_text_swift5_replace,
46
- _dyld_section_location_text_swift5_replace2,
47
- _dyld_section_location_text_swift5_ac_funcs,
48
- };
49
-
50
36
#endif
51
37
38
+ // Bring our own definition of _dyld_section_location constants in case we're
39
+ // using an older SDK that doesn't have them.
40
+ #define _dyld_section_location_text_swift5_protos 0
41
+ #define _dyld_section_location_text_swift5_proto 1
42
+ #define _dyld_section_location_text_swift5_types 2
43
+ #define _dyld_section_location_text_swift5_replace 3
44
+ #define _dyld_section_location_text_swift5_replace2 4
45
+ #define _dyld_section_location_text_swift5_ac_funcs 5
46
+
52
47
#if !OBJC_ADDLOADIMAGEFUNC2_DEFINED
53
48
// If we don't have objc_addLoadImageFunc2, fall back to objc_addLoadImageFunc.
54
49
// Use a #define so we don't have to conditionalize the calling code below.
@@ -80,7 +75,7 @@ using mach_header_platform = mach_header;
80
75
81
76
// Callback for objc_addLoadImageFunc that just takes a mach_header.
82
77
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
83
- enum _dyld_section_location_kind SECTION_KIND,
78
+ int SECTION_KIND,
84
79
void CONSUME_BLOCK (const void *baseAddress, const void *start,
85
80
uintptr_t size)>
86
81
void addImageCallback(const mach_header *mh) {
@@ -103,7 +98,7 @@ void addImageCallback(const mach_header *mh) {
103
98
// Callback for objc_addLoadImageFunc2 that takes a mach_header and dyld info.
104
99
#if OBJC_ADDLOADIMAGEFUNC2_DEFINED
105
100
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
106
- enum _dyld_section_location_kind SECTION_KIND,
101
+ int SECTION_KIND,
107
102
void CONSUME_BLOCK (const void *baseAddress, const void *start,
108
103
uintptr_t size)>
109
104
void addImageCallback(const mach_header *mh,
@@ -121,7 +116,7 @@ void addImageCallback(const mach_header *mh,
121
116
// Callback for _dyld_register_func_for_add_image that takes a mach_header and a
122
117
// slide.
123
118
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
124
- enum _dyld_section_location_kind SECTION_KIND,
119
+ int SECTION_KIND,
125
120
void CONSUME_BLOCK (const void *baseAddress, const void *start,
126
121
uintptr_t size)>
127
122
void addImageCallback(const mach_header *mh, intptr_t vmaddr_slide) {
@@ -132,8 +127,8 @@ void addImageCallback(const mach_header *mh, intptr_t vmaddr_slide) {
132
127
133
128
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
134
129
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
135
- enum _dyld_section_location_kind SECTION_KIND,
136
- enum _dyld_section_location_kind SECTION_KIND2,
130
+ int SECTION_KIND,
131
+ int SECTION_KIND2,
137
132
void CONSUME_BLOCK (const void *baseAddress,
138
133
const void *start, uintptr_t size,
139
134
const void *start2, uintptr_t size2)>
@@ -168,8 +163,8 @@ void addImageCallback2Sections(const mach_header *mh) {
168
163
#if OBJC_ADDLOADIMAGEFUNC2_DEFINED
169
164
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
170
165
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
171
- enum _dyld_section_location_kind SECTION_KIND,
172
- enum _dyld_section_location_kind SECTION_KIND2,
166
+ int SECTION_KIND,
167
+ int SECTION_KIND2,
173
168
void CONSUME_BLOCK (const void *baseAddress,
174
169
const void *start, uintptr_t size,
175
170
const void *start2, uintptr_t size2)>
@@ -198,8 +193,8 @@ void addImageCallback2Sections(const mach_header *mh,
198
193
// slide.
199
194
template <const char *SEGMENT_NAME, const char *SECTION_NAME,
200
195
const char *SEGMENT_NAME2, const char *SECTION_NAME2,
201
- enum _dyld_section_location_kind SECTION_KIND,
202
- enum _dyld_section_location_kind SECTION_KIND2,
196
+ int SECTION_KIND,
197
+ int SECTION_KIND2,
203
198
void CONSUME_BLOCK (const void *baseAddress, const void *start,
204
199
uintptr_t size, const void *start2,
205
200
uintptr_t size2)>
0 commit comments