]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/packed-kext-text/test.py
4 import KernelCollection
6 # __DATA should be packed at sub-page alignment
7 # But only in the kexts. The kernel pages should not be packed
9 def check(kernel_cache
):
10 kernel_cache
.buildKernelCollection("arm64", "/packed-kext-text/main.kc", "/packed-kext-text/main.kernel", "/packed-kext-text/extensions", ["com.apple.foo", "com.apple.bar"], [])
11 kernel_cache
.analyze("/packed-kext-text/main.kc", ["-layout", "-arch", "arm64"])
13 assert kernel_cache
.dictionary()["cache-segments"][2]["name"] == "__TEXT_EXEC"
14 assert kernel_cache
.dictionary()["cache-segments"][2]["vmAddr"] == "0x8000"
15 assert kernel_cache
.dictionary()["cache-segments"][2]["vmSize"] == "0xC000"
17 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
19 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
20 assert kernel_cache
.dictionary()["dylibs"][0]["segments"][1]["name"] == "__TEXT_EXEC"
21 assert kernel_cache
.dictionary()["dylibs"][0]["segments"][1]["vmAddr"] == "0xC000"
22 assert kernel_cache
.dictionary()["dylibs"][0]["segments"][1]["vmSize"] == "0x4000"
24 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
25 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][1]["name"] == "__TEXT_EXEC"
26 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][1]["vmAddr"] == "0x10000"
27 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][1]["vmSize"] == "0x20"
29 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
30 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][1]["name"] == "__TEXT_EXEC"
31 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][1]["vmAddr"] == "0x10020"
32 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][1]["vmSize"] == "0xC"
35 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-static -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text -Wl,-e,__start -Wl,-pagezero_size,0x0 -Wl,-pie main.c -o main.kernel
36 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info foo.c -o extensions/foo.kext/foo
37 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info bar.c -o extensions/bar.kext/bar
38 # [~]> rm -r extensions/*.kext/*.ld