]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/kmod-info/test.py
4 import KernelCollection
6 # Update the kmod_info entry for the files here
8 def check(kernel_cache
):
9 kernel_cache
.buildKernelCollection("x86_64", "/kmod-info/main.kc", "/kmod-info/main.kernel", "/kmod-info/extensions", ["com.apple.foo", "com.apple.bar"], [])
12 kernel_cache
.analyze("/kmod-info/main.kc", ["-layout", "-arch", "x86_64"])
14 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
15 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
17 # Find the address and size of each kext in the layout and check that these match their kmod info values
19 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
20 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][0]["name"] == "__TEXT"
21 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][0]["vmAddr"] == "0x205000"
22 assert kernel_cache
.dictionary()["dylibs"][1]["segments"][0]["vmSize"] == "0xFF8"
24 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
25 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][0]["name"] == "__TEXT"
26 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][0]["vmAddr"] == "0x206000"
27 assert kernel_cache
.dictionary()["dylibs"][2]["segments"][0]["vmSize"] == "0xFF8"
30 kernel_cache
.analyze("/kmod-info/main.kc", ["-kmod", "-arch", "x86_64"])
31 assert len(kernel_cache
.dictionary()) == 3
32 assert kernel_cache
.dictionary()[0]["name"] == "com.apple.kernel"
33 assert kernel_cache
.dictionary()[0]["kmod_info"] == "none"
36 assert kernel_cache
.dictionary()[1]["name"] == "com.apple.bar"
37 assert kernel_cache
.dictionary()[1]["kmod_info"]["info-version"] == "1"
38 assert kernel_cache
.dictionary()[1]["kmod_info"]["name"] == "com.apple.bar"
39 assert kernel_cache
.dictionary()[1]["kmod_info"]["version"] == "1.0.0"
40 assert kernel_cache
.dictionary()[1]["kmod_info"]["address"] == "0x205000"
41 assert kernel_cache
.dictionary()[1]["kmod_info"]["size"] == "0xFF8"
44 assert kernel_cache
.dictionary()[2]["name"] == "com.apple.foo"
45 assert kernel_cache
.dictionary()[2]["kmod_info"]["info-version"] == "1"
46 assert kernel_cache
.dictionary()[2]["kmod_info"]["name"] == "com.apple.foo"
47 assert kernel_cache
.dictionary()[2]["kmod_info"]["version"] == "1.0.0"
48 assert kernel_cache
.dictionary()[2]["kmod_info"]["address"] == "0x206000"
49 assert kernel_cache
.dictionary()[2]["kmod_info"]["size"] == "0xFF8"
51 # [~]> xcrun -sdk macosx.internal cc -arch x86_64 -Wl,-static -mkernel -nostdlib -Wl,-e,__start -Wl,-pie main.c -Wl,-pagezero_size,0x0 -o main.kernel -Wl,-image_base,0x200000 -Wl,-segaddr,__HIB,0x100000 -Wl,-add_split_seg_info -Wl,-install_name,/usr/lib/swift/split.seg.v2.hack
52 # [~]> xcrun -sdk macosx.internal cc -arch x86_64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info foo.c -o extensions/foo.kext/foo
53 # [~]> xcrun -sdk macosx.internal cc -arch x86_64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info bar.c -o extensions/bar.kext/bar
54 # [~]> rm -r extensions/*.kext/*.ld