]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dladdr-basic.dtest/main-no-syms.c
dyld-551.4.tar.gz
[apple/dyld.git] / testing / test-cases / dladdr-basic.dtest / main-no-syms.c
1
2 // BUILD: $CC main-no-syms.c -o $BUILD_DIR/dladdr-stripped.exe
3 // BUILD: strip $BUILD_DIR/dladdr-stripped.exe
4
5 // RUN: ./dladdr-stripped.exe
6
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <dlfcn.h>
12 #include <mach-o/dyld_priv.h>
13
14
15
16 ///
17 /// verify dladdr() returns NULL for a symbol name in a fully stripped
18 /// main executable (and not _mh_execute_header+nnn).
19 ///
20
21 int main()
22 {
23 printf("[BEGIN] dladdr-stripped\n");
24
25 Dl_info info;
26 if ( dladdr(&main, &info) == 0 ) {
27 printf("[FAIL] dladdr(&main, xx) failed\n");
28 return 0;
29 }
30
31 if ( info.dli_sname != NULL ){
32 printf("[FAIL] dladdr() returned: \"%s\" instead of NULL\n", info.dli_sname);
33 return 0;
34 }
35
36 printf("[PASS] dladdr-stripped\n");
37 return 0;
38 }