]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/init-term-segments.dtest/main.c
3 // BUILD: $CC foo.c -dynamiclib -fno-register-global-dtors-with-atexit -Wl,-segprot,__SOMETEXT,rx,rx -Wl,-segprot,__MORETEXT,rx,rx -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
4 // BUILD: $CC main.c -o $BUILD_DIR/init-term-segments.exe -DRUN_DIR="$RUN_DIR"
6 // RUN: ./init-term-segments.exe
12 extern bool foo(bool* ptr
);
16 printf("[BEGIN] init-term-segments\n");
18 void* h
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_NOW
);
20 printf("[FAIL] init-term-segments - dlerror = %s\n", dlerror());
24 void* fooSym
= dlsym(RTLD_DEFAULT
, "foo");
25 if ( fooSym
== NULL
) {
26 printf("[FAIL] init-term-segments - dlsym failure\n");
31 bool ranInit
= ((__typeof(&foo
))fooSym
)(&ranTerm
);
33 printf("[FAIL] init-term-segments - didn't run init\n");
37 if ( dlclose(h
) != 0 ) {
38 printf("[FAIL] init-term-segments - didn't dlclose\n");
43 printf("[FAIL] init-term-segments - didn't run term\n");
47 printf("[PASS] init-term-segments\n");