@@ -60,10 +60,10 @@ struct rebindings_entry {
60
60
struct rebindings_entry * next ;
61
61
};
62
62
63
- static struct rebindings_entry * _rebindings_head ;
63
+ static struct rebindings_entry * _flex_rebindings_head ;
64
64
65
65
/// @return 0 on success
66
- static int prepend_rebindings (struct rebindings_entry * * rebindings_head ,
66
+ static int flex_prepend_rebindings (struct rebindings_entry * * rebindings_head ,
67
67
struct rebinding rebindings [],
68
68
size_t nel ) {
69
69
struct rebindings_entry * new_entry = (struct rebindings_entry * ) malloc (sizeof (struct rebindings_entry ));
@@ -85,7 +85,7 @@ static int prepend_rebindings(struct rebindings_entry **rebindings_head,
85
85
return 0 ;
86
86
}
87
87
88
- static vm_prot_t get_protection (void * sectionStart ) {
88
+ static vm_prot_t flex_get_protection (void * sectionStart ) {
89
89
mach_port_t task = mach_task_self ();
90
90
vm_size_t size = 0 ;
91
91
vm_address_t address = (vm_address_t )sectionStart ;
@@ -110,19 +110,19 @@ static vm_prot_t get_protection(void *sectionStart) {
110
110
return VM_PROT_READ ;
111
111
}
112
112
}
113
- static void perform_rebinding_with_section (struct rebindings_entry * rebindings ,
114
- section_t * section ,
115
- intptr_t slide ,
116
- nlist_t * symtab ,
117
- char * strtab ,
118
- uint32_t * indirect_symtab ) {
113
+ static void flex_perform_rebinding_with_section (struct rebindings_entry * rebindings ,
114
+ section_t * section ,
115
+ intptr_t slide ,
116
+ nlist_t * symtab ,
117
+ char * strtab ,
118
+ uint32_t * indirect_symtab ) {
119
119
const bool isDataConst = strcmp (section -> segname , "__DATA_CONST" ) == 0 ;
120
120
uint32_t * indirect_symbol_indices = indirect_symtab + section -> reserved1 ;
121
121
void * * indirect_symbol_bindings = (void * * )((uintptr_t )slide + section -> addr );
122
122
vm_prot_t oldProtection = VM_PROT_READ ;
123
123
124
124
if (isDataConst ) {
125
- oldProtection = get_protection (rebindings );
125
+ oldProtection = flex_get_protection (rebindings );
126
126
mprotect (indirect_symbol_bindings , section -> size , PROT_READ | PROT_WRITE );
127
127
}
128
128
@@ -177,9 +177,9 @@ static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
177
177
}
178
178
}
179
179
180
- static void rebind_symbols_for_image (struct rebindings_entry * rebindings ,
181
- const struct mach_header * header ,
182
- intptr_t slide ) {
180
+ static void flex_rebind_symbols_for_image (struct rebindings_entry * rebindings ,
181
+ const struct mach_header * header ,
182
+ intptr_t slide ) {
183
183
Dl_info info ;
184
184
if (dladdr (header , & info ) == 0 ) {
185
185
return ;
@@ -232,12 +232,12 @@ static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
232
232
section_t * sect = (section_t * )(cur + sizeof (segment_command_t )) + j ;
233
233
234
234
if ((sect -> flags & SECTION_TYPE ) == S_LAZY_SYMBOL_POINTERS ) {
235
- perform_rebinding_with_section (
235
+ flex_perform_rebinding_with_section (
236
236
rebindings , sect , slide , symtab , strtab , indirect_symtab
237
237
);
238
238
}
239
239
if ((sect -> flags & SECTION_TYPE ) == S_NON_LAZY_SYMBOL_POINTERS ) {
240
- perform_rebinding_with_section (
240
+ flex_perform_rebinding_with_section (
241
241
rebindings , sect , slide , symtab , strtab , indirect_symtab
242
242
);
243
243
}
@@ -246,19 +246,19 @@ static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
246
246
}
247
247
}
248
248
249
- static void _rebind_symbols_for_image (const struct mach_header * header ,
250
- intptr_t slide ) {
251
- rebind_symbols_for_image ( _rebindings_head , header , slide );
249
+ static void _flex_rebind_symbols_for_image (const struct mach_header * header ,
250
+ intptr_t slide ) {
251
+ flex_rebind_symbols_for_image ( _flex_rebindings_head , header , slide );
252
252
}
253
253
254
- int rebind_symbols_image (void * header ,
255
- intptr_t slide ,
256
- struct rebinding rebindings [],
257
- size_t rebindings_nel ) {
254
+ int flex_rebind_symbols_image (void * header ,
255
+ intptr_t slide ,
256
+ struct rebinding rebindings [],
257
+ size_t rebindings_nel ) {
258
258
struct rebindings_entry * rebindings_head = NULL ;
259
259
260
- int retval = prepend_rebindings (& rebindings_head , rebindings , rebindings_nel );
261
- rebind_symbols_for_image (rebindings_head , (const struct mach_header * ) header , slide );
260
+ int retval = flex_prepend_rebindings (& rebindings_head , rebindings , rebindings_nel );
261
+ flex_rebind_symbols_for_image (rebindings_head , (const struct mach_header * ) header , slide );
262
262
263
263
if (rebindings_head ) {
264
264
free (rebindings_head -> rebindings );
@@ -269,20 +269,20 @@ int rebind_symbols_image(void *header,
269
269
}
270
270
271
271
/// @return 0 on success
272
- int rebind_symbols (struct rebinding rebindings [], size_t rebindings_nel ) {
273
- int retval = prepend_rebindings ( & _rebindings_head , rebindings , rebindings_nel );
272
+ int flex_rebind_symbols (struct rebinding rebindings [], size_t rebindings_nel ) {
273
+ int retval = flex_prepend_rebindings ( & _flex_rebindings_head , rebindings , rebindings_nel );
274
274
if (retval < 0 ) {
275
275
return retval ;
276
276
}
277
277
278
278
// If this was the first call, register callback for image additions (which is also invoked for
279
279
// existing images, otherwise, just run on existing images
280
- if (!_rebindings_head -> next ) {
281
- _dyld_register_func_for_add_image (_rebind_symbols_for_image );
280
+ if (!_flex_rebindings_head -> next ) {
281
+ _dyld_register_func_for_add_image (_flex_rebind_symbols_for_image );
282
282
} else {
283
283
uint32_t c = _dyld_image_count ();
284
284
for (uint32_t i = 0 ; i < c ; i ++ ) {
285
- _rebind_symbols_for_image (_dyld_get_image_header (i ), _dyld_get_image_vmaddr_slide (i ));
285
+ _flex_rebind_symbols_for_image (_dyld_get_image_header (i ), _dyld_get_image_vmaddr_slide (i ));
286
286
}
287
287
}
288
288
0 commit comments