]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/ppl-data-const/test.py
4 import KernelCollection
6 # PPL data const should be folded in under data const and allowed to have fixups
8 def check(kernel_cache
):
9 kernel_cache
.buildKernelCollection("arm64", "/ppl-data-const/main.kc", "/ppl-data-const/main.kernel", "/ppl-data-const/extensions", ["com.apple.foo", "com.apple.bar"], [])
10 kernel_cache
.analyze("/ppl-data-const/main.kc", ["-layout", "-arch", "arm64"])
12 assert kernel_cache
.dictionary()["cache-segments"][3]["name"] == "__DATA_CONST"
13 assert kernel_cache
.dictionary()["cache-segments"][3]["vmAddr"] == "0x18000"
14 assert kernel_cache
.dictionary()["cache-segments"][3]["vmSize"] == "0x8000"
16 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
18 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
19 assert kernel_cache
.dictionary()["dylibs"][0]["segments"][3]["name"] == "__PPLDATA_CONST"
20 assert kernel_cache
.dictionary()["dylibs"][0]["segments"][3]["vmAddr"] == "0x18000"
22 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
24 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
26 # Check we have the correct addresses of the symbols being bound to
27 kernel_cache
.analyze("/ppl-data-const/main.kc", ["-symbols", "-arch", "arm64"])
30 assert kernel_cache
.dictionary()["dylibs"][0]["global-symbols"][3]["name"] == "_x"
31 assert kernel_cache
.dictionary()["dylibs"][0]["global-symbols"][3]["vmAddr"] == "0x24000"
34 assert kernel_cache
.dictionary()["dylibs"][2]["global-symbols"][0]["name"] == "_foo"
35 assert kernel_cache
.dictionary()["dylibs"][2]["global-symbols"][0]["vmAddr"] == "0x14030"
37 kernel_cache
.analyze("/ppl-data-const/main.kc", ["-fixups", "-arch", "arm64"])
40 assert kernel_cache
.dictionary()["fixups"]["0x18000"] == "kc(0) + 0x24000"
43 assert kernel_cache
.dictionary()["fixups"]["0x1C000"] == "kc(0) + 0x14030"
45 # [~]> 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 -Wl,-rename_section,__DATA,__data,__PPLDATA_CONST,__data -Wl,-segprot,__PPLDATA_CONST,r--,r-- main.c -o main.kernel
46 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info foo.c -o extensions/foo.kext/foo
47 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info bar.c -o extensions/bar.kext/bar
48 # [~]> rm -r extensions/*.kext/*.ld