]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/_dyld_is_memory_immutable-lock.dtest/main.c
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>
14 #include "test_support.h"
16 static void* work(void* mh
)
18 _dyld_is_memory_immutable(mh
, 16);
23 static void notify(const struct mach_header
* mh
, intptr_t vmaddr_slide
)
25 if ( mh
->flags
& 0x80000000 )
28 // for each image notified that is not in the dyld cache, spin up a thread which calls _dyld_is_memory_immutable()
29 pthread_t workerThread
;
30 if ( pthread_create(&workerThread
, NULL
, &work
, (void*)mh
) != 0 ) {
31 FAIL("pthread_create");
34 pthread_join(workerThread
, &dummy
);
39 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
40 _dyld_register_func_for_add_image(¬ify
);
42 void* h
= dlopen(RUN_DIR
"/lock.bundle", 0);
44 FAIL("lock.bundle not loaded, dlopen(lock.bundle) failed with error: %s", dlerror());