]> git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/packed-kext-data/test.py
dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / packed-kext-data / test.py
1 #!/usr/bin/python2.7
2
3 import os
4 import KernelCollection
5
6 # __DATA should be packed at sub-page alignment
7 # But only in the kexts. The kernel pages should not be packed
8
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"])
12
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"
17
18 assert len(kernel_cache.dictionary()["dylibs"]) == 3
19 # bar.kext
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"
24 # foo.kext
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"
30
31
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
36