]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/init-term-segments.dtest/main.c
f0ef7b813fd4d2cec667cb805d63bd0c349d43c5
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 #include "test_support.h"
14 extern bool foo(bool* ptr
);
16 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
17 void* h
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_NOW
);
19 FAIL("dlerror = %s", dlerror());
22 void* fooSym
= dlsym(RTLD_DEFAULT
, "foo");
23 if ( fooSym
== NULL
) {
24 FAIL("dlsym failure");
28 bool ranInit
= ((__typeof(&foo
))fooSym
)(&ranTerm
);
30 FAIL("didn't run init");
33 if ( dlclose(h
) != 0 ) {
34 FAIL("didn't dlclose");
38 FAIL("didn't run term");