]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/_dyld_get_objc_selector-shared-cache.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / _dyld_get_objc_selector-shared-cache.dtest / main.c
1
2 // BUILD: $CC main.c -o $BUILD_DIR/_dyld_get_objc_selector-shared-cache.exe
3
4 // RUN: ./_dyld_get_objc_selector-shared-cache.exe
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <dlfcn.h>
9 #include <mach-o/dyld.h>
10 #include <mach-o/dyld_priv.h>
11
12 #include "test_support.h"
13
14 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
15 size_t cacheLen;
16 uintptr_t cacheStart = (uintptr_t)_dyld_get_shared_cache_range(&cacheLen);
17
18 const char* selName = _dyld_get_objc_selector("retain");
19
20 if ( cacheStart != 0 ) {
21 // We have a shared cache, so the selector should be there
22 if ( selName == NULL ) {
23 FAIL("_dyld_get_objc_selector() returned null for selector in shared cache");
24 }
25
26 if ( ((uintptr_t)selName < cacheStart) || ((uintptr_t)selName >= (cacheStart + cacheLen)) ) {
27 FAIL("_dyld_get_objc_selector() pointer outside of shared cache range");
28 }
29 } else {
30 // No shared cache, so the selector should not be found.
31 // FIXME: This assumption may be false once the selectors are in the closure.
32 if ( selName != NULL ) {
33 FAIL("_dyld_get_objc_selector() returned non-null for selector without shared cache");
34 }
35 }
36
37 PASS("Success");
38 }
39