]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/kernel-auxkc-fixups.dtest/bar.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / kernel-auxkc-fixups.dtest / bar.c
1
2 #include "../kernel-test-runner.h"
3
4 extern int kernelExport();
5 __typeof(&kernelExport) kernelExportPtr = &kernelExport;
6
7 int bar() {
8 return kernelExportPtr() + 2;
9 }
10
11 extern int kernelExportDirect();
12
13 // Test direct pointer fixups to the kernel. On x86_64 these would be emitted as just
14 // a branch relocation so we needed to synthesize a stub
15 __attribute__((constructor))
16 int testDirectToKernel(const TestRunnerFunctions* funcs) {
17 LOG("testDirectToKernel(): start");
18 // The kernel returned 42
19 int v = kernelExportDirect();
20 if ( v != 42 ) {
21 FAIL("kernelExportDirect() returned %d vs expected 42", v);
22 }
23 LOG("testDirectToKernel(): end");
24 return 0;
25 }