]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dladdr-dylib.dtest/foo.c
7 #include <mach-o/dyld_priv.h>
9 extern void* __dso_handle
;
16 static int dylib_foo()
21 __attribute__((visibility("hidden"))) int dylib_hide()
26 // checks global symbol
27 static void verifybar()
30 if ( dladdr(&dylib_bar
, &info
) == 0 ) {
31 printf("[FAIL] dladdr(&dylib_bar, xx) failed\n");
34 if ( strcmp(info
.dli_sname
, "dylib_bar") != 0 ) {
35 printf("[FAIL] dladdr()->dli_sname is \"%s\" instead of \"dylib_bar\"\n", info
.dli_sname
);
38 if ( info
.dli_saddr
!= &dylib_bar
) {
39 printf("[FAIL] dladdr()->dli_saddr is not &dylib_bar\n");
42 if ( info
.dli_fbase
!= &__dso_handle
) {
43 printf("[FAIL] dladdr()->dli_fbase is not image that contains &dylib_bar\n");
48 // checks local symbol
49 static void verifyfoo()
52 if ( dladdr(&dylib_foo
, &info
) == 0 ) {
53 printf("[FAIL] dladdr(&dylib_foo, xx) failed\n");
56 if ( strcmp(info
.dli_sname
, "dylib_foo") != 0 ) {
57 printf("[FAIL] dladdr()->dli_sname is \"%s\" instead of \"dylib_foo\"\n", info
.dli_sname
);
60 if ( info
.dli_saddr
!= &dylib_foo
) {
61 printf("[FAIL] dladdr()->dli_saddr is not &dylib_foo\n");
64 if ( info
.dli_fbase
!= &__dso_handle
) {
65 printf("[FAIL] dladdr()->dli_fbase is not image that contains &dylib_foo\n");
70 // checks hidden symbol
71 static void verifyhide()
74 if ( dladdr(&dylib_hide
, &info
) == 0 ) {
75 printf("[FAIL] dladdr(&dylib_hide, xx) failed\n");
78 if ( strcmp(info
.dli_sname
, "dylib_hide") != 0 ) {
79 printf("[FAIL] dladdr()->dli_sname is \"%s\" instead of \"dylib_hide\"\n", info
.dli_sname
);
82 if ( info
.dli_saddr
!= &dylib_hide
) {
83 printf("[FAIL] dladdr()->dli_saddr is not &dylib_hide\n");
86 if ( info
.dli_fbase
!= &__dso_handle
) {
87 printf("[FAIL] dladdr()->dli_fbase is not image that contains &dylib_hide\n");