dyld-625.13.tar.gz
[apple/dyld.git] / testing / test-cases / dylib-static-weak-link.dtest / present.c
1 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
2 // BUILD: $CC present.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/dylib-static-weak-present.exe
3 // BUILD: $CC foo.c -dynamiclib -o $TEMP_DIR/libfoo2.dylib -install_name $RUN_DIR/libfoomissing.dylib
4 // BUILD: $CC missing.c $TEMP_DIR/libfoo2.dylib -o $BUILD_DIR/dylib-static-weak-missing.exe
5
6 // RUN: ./dylib-static-weak-present.exe
7 // RUN: ./dylib-static-weak-missing.exe
8
9
10 #include <stddef.h>
11 #include <stdio.h>
12
13 extern int foo __attribute__((weak_import));
14
15
16 int main()
17 {
18 printf("[BEGIN] dylib-static-weak-link present\n");
19 // dylib will be found at runtime, so &foo should never be NULL
20 if ( &foo != NULL ) {
21 if ( foo == 42 )
22 printf("[PASS] dylib-static-weak-link present\n");
23 else
24 printf("[FAIL] dylib-static-weak-link present, wrong value\n");
25 }
26 else {
27 printf("[FAIL] dylib-static-weak-link present, &foo == NULL\n");
28 }
29
30 return 0;
31 }
32
33