]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/packed-kext-data/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-data/main.kc", "/packed-kext-data/main.kernel", "/packed-kext-data/extensions", ["com.apple.foo", "com.apple.bar"], [])
11 kernel_cache
.analyze("/packed-kext-data/main.kc", ["-layout", "-arch", "arm64"])
13 assert len(kernel_cache
.dictionary()["cache-segments"]) == 7
14 assert kernel_cache
.dictionary()["cache-segments"][5]["name"] == "__DATA"
15 assert kernel_cache
.dictionary()["cache-segments"][5]["vmAddr"] == "0x20000"
16 assert kernel_cache
.dictionary()["cache-segments"][5]["vmSize"] == "0x4000"
18 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
20 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
21 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][2]["name"] == "__DATA"
22 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][2]["vmAddr"] == "0x20000"
23 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][2]["vmSize"] == "0x4"
25 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
26 assert len(kernel_cache
.dictionary()["dylibs"][2]["segments"]) == 4
27 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][2]["name"] == "__DATA"
28 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][2]["vmAddr"] == "0x20004"
29 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][2]["vmSize"] == "0x4"
32 # [~]> 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
33 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info foo.c -o extensions/foo.kext/foo
34 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info bar.c -o extensions/bar.kext/bar
35 # [~]> rm -r extensions/*.kext/*.ld