]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/auxkc-kext-bind-to-kernel/test.py
4 import KernelCollection
6 # This verifies that we use the symbol set when resolving symbols from aux KC to the kernel
8 def check(kernel_cache
):
9 kernel_cache
.buildKernelCollection("arm64", "/auxkc-kext-bind-to-kernel/main.kc", "/auxkc-kext-bind-to-kernel/main.kernel", "/auxkc-kext-bind-to-kernel/extensions", ["com.apple.bar"], [])
10 kernel_cache
.analyze("/auxkc-kext-bind-to-kernel/main.kc", ["-layout", "-arch", "arm64"])
12 assert len(kernel_cache
.dictionary()["dylibs"]) == 1
13 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
15 # Now build an aux cache using the baseline kernel collection
16 kernel_cache
.buildAuxKernelCollection("arm64", "/auxkc-kext-bind-to-kernel/aux.kc", "/auxkc-kext-bind-to-kernel/main.kc", "", "/auxkc-kext-bind-to-kernel/extensions", ["com.apple.foo"], [])
17 kernel_cache
.analyze("/auxkc-kext-bind-to-kernel/aux.kc", ["-layout", "-arch", "arm64"])
20 kernel_cache
.analyze("/auxkc-kext-bind-to-kernel/aux.kc", ["-fixups", "-arch", "arm64"])
21 assert len(kernel_cache
.dictionary()["fixups"]) == 1
22 assert kernel_cache
.dictionary()["fixups"]["0x4000"] == "kc(0) + 0x8000"
23 assert len(kernel_cache
.dictionary()["dylibs"]) == 1
24 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.foo"
25 assert kernel_cache
.dictionary()["dylibs"][0]["fixups"] == "none"
27 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-static -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-no_data_const -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text -Wl,-e,__start -Wl,-pagezero_size,0x0 -Wl,-pie main.c -o main.kernel -Wl,-sectcreate,__LINKINFO,__symbolsets,SymbolSets.plist -Wl,-segprot,__LINKINFO,r--,r--
28 # [~]> 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
29 # [~]> rm -r extensions/foo.kext/*.ld