]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/_dyld_is_memory_immutable-lock.dtest/main.c
e35435fa91a61355d2254b3801df5cb53c28339c
3 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/lock.bundle
4 // BUILD: $CC main.c -o $BUILD_DIR/immutable-lock.exe -DRUN_DIR="$RUN_DIR"
6 // RUN: ./immutable-lock.exe
12 #include <mach-o/dyld_priv.h>
15 static void* work(void* mh
)
17 _dyld_is_memory_immutable(mh
, 16);
22 static void notify(const struct mach_header
* mh
, intptr_t vmaddr_slide
)
24 if ( mh
->flags
& 0x80000000 )
27 // for each image notified that is not in the dyld cache, spin up a thread which calls _dyld_is_memory_immutable()
28 pthread_t workerThread
;
29 if ( pthread_create(&workerThread
, NULL
, &work
, (void*)mh
) != 0 ) {
30 printf("[FAIL] _dyld_is_memory_immutable-lock, pthread_create\n");
34 pthread_join(workerThread
, &dummy
);
41 printf("[BEGIN] _dyld_is_memory_immutable-lock\n");
43 _dyld_register_func_for_add_image(¬ify
);
45 void* h
= dlopen(RUN_DIR
"/lock.bundle", 0);
47 printf("dlopen(lock.bundle) failed with error: %s\n", dlerror());
48 printf("[FAIL] _dyld_is_memory_immutable-lock, lock.bundle not loaded\n");
52 printf("[PASS] _dyld_is_memory_immutable-lock\n");