]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/kernel-fixups.dtest/main.c
2 // BOOT_ARGS: amfi=3 cs_enforcement_disable=1
4 // BUILD(macos,ios,tvos,bridgeos|x86_64,arm64,arm64e): $CC main.c -o $BUILD_DIR/kernel-fixups.exe -Wl,-static -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-e,__start -Wl,-pie -Wl,-pagezero_size,0x0 -Wl,-install_name,/usr/lib/swift/split.seg.v2.hack -fno-stack-protector -fno-builtin -ffreestanding -Wl,-segprot,__HIB,rx,rx -Wl,-image_base,0x8000 -Wl,-segaddr,__HIB,0x4000 -fno-ptrauth-function-pointer-type-discrimination -ftrivial-auto-var-init=uninitialized
5 // BUILD(macos,ios,tvos,bridgeos|x86_64,arm64,arm64e): $APP_CACHE_UTIL -create-kernel-collection $BUILD_DIR/kernel.kc -kernel $BUILD_DIR/kernel-fixups.exe
10 // RUN_STATIC: $RUN_STATIC ./kernel.kc
12 #include "../kernel-test-runner.h"
13 #include "../kernel-fixups.h"
14 #include "../kernel-classic-relocs.h"
16 #define printf(...) funcs->printf(__VA_ARGS__)
22 __attribute__((section(("__HIB, __text"))))
24 __attribute__((section(("__TEXT_EXEC, __text"))))
26 int _start(const TestRunnerFunctions
* funcs
)
30 const void* slideBasePointers
[4];
31 slideBasePointers
[0] = funcs
->basePointers
[0];
32 slideBasePointers
[1] = funcs
->basePointers
[1];
33 slideBasePointers
[2] = funcs
->basePointers
[2];
34 slideBasePointers
[3] = funcs
->basePointers
[3];
35 int slideReturnCode
= slide(funcs
->mhs
[0], slideBasePointers
, funcs
->printf
);
36 if ( slideReturnCode
!= 0 ) {
37 FAIL("slide = %d\n", slideReturnCode
);
41 int slideClassicReturnCode
= slideClassic(funcs
->mhs
[0], funcs
->printf
);
42 if ( slideClassicReturnCode
!= 0 ) {
43 FAIL("mhs[0] slide classic = %d\n", slideClassicReturnCode
);
50 FAIL("g[0] != x, %d != %d\n", g
[0], x
);