]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/kernel-fixups-x86_64.dtest/main.c
f5bc35193ac9d8055ed1268f49b3aec18e5dbe8e
2 // BOOT_ARGS: amfi=3 cs_enforcement_disable=1
4 // BUILD(macos|x86_64): $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
5 // BUILD(macos|x86_64): $APP_CACHE_UTIL -create-kernel-collection $BUILD_DIR/kernel.kc -kernel $BUILD_DIR/kernel-fixups.exe
7 // BUILD(ios,tvos,watchos,bridgeos):
9 // RUN_STATIC: $RUN_STATIC ./kernel.kc
11 // This tests that unaligned fixups work in x86_64
13 #include "../kernel-test-runner.h"
14 #include "../kernel-fixups.h"
15 #include "../kernel-classic-relocs.h"
17 #define printf(...) funcs->printf(__VA_ARGS__)
21 struct __attribute__((packed
)) __attribute__((aligned((4096)))) PackedS
{
22 int i0
; // aligned to 8
23 int* p0
; // aligned to 4
24 int i1
; // aligned to 4
25 int* p1
; // aligned to 8
26 char i2
; // aligned to 8
27 int* p2
; // aligned to 1
29 struct PackedS ps
= { 0, &x
, 0, &x
, 0, &x
};
31 __attribute__((section(("__HIB, __text"))))
32 int _start(const TestRunnerFunctions
* funcs
)
36 const void* slideBasePointers
[4];
37 slideBasePointers
[0] = funcs
->basePointers
[0];
38 slideBasePointers
[1] = funcs
->basePointers
[1];
39 slideBasePointers
[2] = funcs
->basePointers
[2];
40 slideBasePointers
[3] = funcs
->basePointers
[3];
41 int slideReturnCode
= slide(funcs
->mhs
[0], slideBasePointers
, funcs
->printf
);
42 if ( slideReturnCode
!= 0 ) {
43 FAIL("slide = %d\n", slideReturnCode
);
47 int slideClassicReturnCode
= slideClassic(funcs
->mhs
[0], funcs
->printf
);
48 if ( slideClassicReturnCode
!= 0 ) {
49 FAIL("mhs[0] slide classic = %d\n", slideClassicReturnCode
);
55 if ( ps
.p0
[0] != x
) {
56 FAIL("ps.p1[0] != x, %d != %d\n", ps
.p0
[0], x
);
60 if ( ps
.p1
[0] != x
) {
61 FAIL("ps.p1[0] != x, %d != %d\n", ps
.p1
[0], x
);
65 if ( ps
.p2
[0] != x
) {
66 FAIL("ps.p2[0] != x, %d != %d\n", ps
.p2
[0], x
);