26
26
#include "exec_context.h"
27
27
#include "fileio.h"
28
28
#include "instance.h"
29
- #include "list.h"
30
29
#include "load_context.h"
31
30
#include "mem.h"
32
31
#include "module.h"
32
+ #include "slist.h"
33
33
#include "type.h"
34
34
#include "util.h"
35
35
#include "xlog.h"
@@ -250,7 +250,7 @@ static bool
250
250
is_main_object (struct dyld_object * obj )
251
251
{
252
252
struct dyld * dyld = obj -> dyld ;
253
- return LIST_FIRST (& dyld -> objs ) == obj ;
253
+ return SLIST_FIRST (& dyld -> objs ) == obj ;
254
254
}
255
255
256
256
void
268
268
dyld_init (struct dyld * d , struct mem_context * mctx )
269
269
{
270
270
memset (d , 0 , sizeof (* d ));
271
- LIST_HEAD_INIT (& d -> objs );
271
+ SLIST_HEAD_INIT (& d -> objs );
272
272
d -> table_base = 0 ;
273
273
d -> memory_base = 0 ;
274
274
dyld_options_set_defaults (& d -> opts );
@@ -279,7 +279,7 @@ static struct dyld_object *
279
279
dyld_find_object_by_name (struct dyld * d , const struct name * name )
280
280
{
281
281
struct dyld_object * obj ;
282
- LIST_FOREACH (obj , & d -> objs , q ) {
282
+ SLIST_FOREACH (obj , & d -> objs , q ) {
283
283
if (is_main_object (obj )) {
284
284
continue ;
285
285
}
@@ -338,7 +338,7 @@ dyld_load_needed_objects(struct dyld *d, struct dyld_object *start)
338
338
*/
339
339
int ret = 0 ;
340
340
struct dyld_object * obj ;
341
- for (obj = start ; obj != NULL ; obj = LIST_NEXT (obj , q )) {
341
+ for (obj = start ; obj != NULL ; obj = SLIST_NEXT (obj , q )) {
342
342
const struct dylink_needs * needs = & obj -> module -> dylink -> needs ;
343
343
uint32_t i ;
344
344
for (i = 0 ; i < needs -> count ; i ++ ) {
@@ -732,7 +732,7 @@ dyld_execute_obj_init_func(struct dyld_object *obj, const struct name *names,
732
732
return 0 ;
733
733
}
734
734
735
- LIST_HEAD_NAMED (struct dyld_object , tsort_list );
735
+ SLIST_HEAD_NAMED (struct dyld_object , tsort_list );
736
736
737
737
static void
738
738
tsort_visit (struct dyld_object * obj , struct tsort_list * list )
@@ -752,31 +752,31 @@ tsort_visit(struct dyld_object *obj, struct tsort_list *list)
752
752
assert (needed_obj != NULL );
753
753
tsort_visit (needed_obj , list );
754
754
}
755
- LIST_INSERT_TAIL (list , obj , tq );
755
+ SLIST_INSERT_TAIL (list , obj , tq );
756
756
}
757
757
758
758
int
759
759
dyld_execute_all_init_funcs (struct dyld * d , struct dyld_object * start )
760
760
{
761
761
/* topological sort */
762
762
struct tsort_list list ;
763
- LIST_HEAD_INIT (& list );
763
+ SLIST_HEAD_INIT (& list );
764
764
struct dyld_object * obj ;
765
- for (obj = start ; obj != NULL ; obj = LIST_NEXT (obj , q )) {
765
+ for (obj = start ; obj != NULL ; obj = SLIST_NEXT (obj , q )) {
766
766
assert (!obj -> visited );
767
767
}
768
- for (obj = start ; obj != NULL ; obj = LIST_NEXT (obj , q )) {
768
+ for (obj = start ; obj != NULL ; obj = SLIST_NEXT (obj , q )) {
769
769
tsort_visit (obj , & list );
770
770
}
771
771
772
- LIST_FOREACH (obj , & list , tq ) {
772
+ SLIST_FOREACH (obj , & list , tq ) {
773
773
int ret = dyld_execute_obj_init_func (obj , reloc_funcs ,
774
774
ARRAYCOUNT (reloc_funcs ));
775
775
if (ret != 0 ) {
776
776
return ret ;
777
777
}
778
778
}
779
- LIST_FOREACH (obj , & list , tq ) {
779
+ SLIST_FOREACH (obj , & list , tq ) {
780
780
int ret = dyld_execute_obj_init_func (obj , ctor_funcs ,
781
781
ARRAYCOUNT (ctor_funcs ));
782
782
if (ret != 0 ) {
@@ -838,7 +838,7 @@ dyld_load_object_from_file(struct dyld *d, const struct name *name,
838
838
* otherwise, it's probably non-pie.
839
839
*/
840
840
bool pie_or_lib ;
841
- if (LIST_EMPTY (& d -> objs )) {
841
+ if (SLIST_EMPTY (& d -> objs )) {
842
842
/* the main module */
843
843
d -> pie = pie_or_lib = module_imports_env_memory (obj -> module );
844
844
if (d -> pie ) {
@@ -900,7 +900,7 @@ dyld_load_object_from_file(struct dyld *d, const struct name *name,
900
900
if (ret != 0 ) {
901
901
goto fail ;
902
902
}
903
- LIST_INSERT_TAIL (& d -> objs , obj , q );
903
+ SLIST_INSERT_TAIL (& d -> objs , obj , q );
904
904
xlog_trace ("dyld: %.*s loaded" , CSTR (name ));
905
905
if (objp != NULL ) {
906
906
* objp = obj ;
@@ -1210,7 +1210,7 @@ dyld_resolve_symbol(struct dyld_object *refobj, enum symtype symtype,
1210
1210
{
1211
1211
struct dyld * d = refobj -> dyld ;
1212
1212
struct dyld_object * obj ;
1213
- LIST_FOREACH (obj , & d -> objs , q ) {
1213
+ SLIST_FOREACH (obj , & d -> objs , q ) {
1214
1214
int ret = dyld_resolve_symbol_in_obj (refobj , obj , symtype , sym ,
1215
1215
resultp );
1216
1216
if (ret == 0 ) {
@@ -1263,7 +1263,7 @@ static int
1263
1263
dyld_resolve_all_got_symbols (struct dyld * d , struct dyld_object * start )
1264
1264
{
1265
1265
struct dyld_object * obj ;
1266
- for (obj = start ; obj != NULL ; obj = LIST_NEXT (obj , q )) {
1266
+ for (obj = start ; obj != NULL ; obj = SLIST_NEXT (obj , q )) {
1267
1267
int ret = dyld_resolve_got_symbols (obj );
1268
1268
if (ret != 0 ) {
1269
1269
return ret ;
@@ -1302,7 +1302,7 @@ static int
1302
1302
dyld_resolve_all_plt_symbols (struct dyld * d , struct dyld_object * start )
1303
1303
{
1304
1304
struct dyld_object * obj ;
1305
- for (obj = start ; obj != NULL ; obj = LIST_NEXT (obj , q )) {
1305
+ for (obj = start ; obj != NULL ; obj = SLIST_NEXT (obj , q )) {
1306
1306
int ret = dyld_resolve_plt_symbols (obj );
1307
1307
if (ret != 0 ) {
1308
1308
return ret ;
@@ -1388,7 +1388,7 @@ dyld_load(struct dyld *d, const char *filename)
1388
1388
int
1389
1389
dyld_execute_init_funcs (struct dyld * d )
1390
1390
{
1391
- struct dyld_object * obj = LIST_FIRST (& d -> objs );
1391
+ struct dyld_object * obj = SLIST_FIRST (& d -> objs );
1392
1392
return dyld_execute_all_init_funcs (d , obj );
1393
1393
}
1394
1394
@@ -1397,8 +1397,8 @@ dyld_clear(struct dyld *d)
1397
1397
{
1398
1398
struct mem_context * mctx = d -> mctx ;
1399
1399
struct dyld_object * obj ;
1400
- while ((obj = LIST_FIRST (& d -> objs )) != NULL ) {
1401
- LIST_REMOVE (& d -> objs , obj , q );
1400
+ while ((obj = SLIST_FIRST (& d -> objs )) != NULL ) {
1401
+ SLIST_REMOVE (& d -> objs , ( struct dyld_object * ) NULL , obj , q );
1402
1402
dyld_object_destroy (obj );
1403
1403
}
1404
1404
if (d -> pie ) {
@@ -1433,7 +1433,7 @@ dyld_clear(struct dyld *d)
1433
1433
struct instance *
1434
1434
dyld_main_object_instance (struct dyld * d )
1435
1435
{
1436
- const struct dyld_object * obj = LIST_FIRST (& d -> objs );
1436
+ const struct dyld_object * obj = SLIST_FIRST (& d -> objs );
1437
1437
return obj -> instance ;
1438
1438
}
1439
1439
0 commit comments