]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/auxkc-bind-to-pageablekc/test.py
4 import KernelCollection
6 # This verifies that a kext can bind to another kext
7 # foo.kext exports foo and bar.kext uses it
9 def check(kernel_cache
):
10 kernel_cache
.buildKernelCollection("arm64", "/auxkc-bind-to-pageablekc/main.kc", "/auxkc-bind-to-pageablekc/main.kernel", "", [], [])
11 kernel_cache
.analyze("/auxkc-bind-to-pageablekc/main.kc", ["-layout", "-arch", "arm64"])
13 # Now build an pageable cache using the baseline kernel collection
14 kernel_cache
.buildPageableKernelCollection("arm64", "/auxkc-bind-to-pageablekc/pageable.kc", "/auxkc-bind-to-pageablekc/main.kc", "/auxkc-bind-to-pageablekc/extensions", ["com.apple.foo"], [])
15 kernel_cache
.analyze("/auxkc-bind-to-pageablekc/pageable.kc", ["-symbols", "-arch", "arm64"])
17 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.foo"
18 assert kernel_cache
.dictionary()["dylibs"][0]["global-symbols"][0]["name"] == "_foo"
19 assert kernel_cache
.dictionary()["dylibs"][0]["global-symbols"][0]["vmAddr"] == "0x8000"
21 # Now build an aux cache using the baseline and pageable kernel collections
22 kernel_cache
.buildAuxKernelCollection("arm64", "/auxkc-bind-to-pageablekc/aux.kc", "/auxkc-bind-to-pageablekc/main.kc", "/auxkc-bind-to-pageablekc/pageable.kc", "/auxkc-bind-to-pageablekc/extensions", ["com.apple.bar"], [])
23 kernel_cache
.analyze("/auxkc-bind-to-pageablekc/aux.kc", ["-fixups", "-arch", "arm64"])
26 assert len(kernel_cache
.dictionary()["fixups"]) == 1
28 assert kernel_cache
.dictionary()["fixups"]["0x4000"] == "kc(1) + 0x8000"
31 # [~]> 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
32 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-no_data_const foo.c -o extensions/foo.kext/foo
33 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-no_data_const bar.c -o extensions/bar.kext/bar
34 # [~]> rm -r extensions/*.kext/*.ld