]> git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/auxkc-kext-bind-to-kernel-codeless-kext/test.py
dyld-851.27.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / auxkc-kext-bind-to-kernel-codeless-kext / test.py
1 #!/usr/bin/python2.7
2
3 import os
4 import KernelCollection
5
6 # codeless kext's are in the PRELINK_INFO in the baseKC, but can be a dependency for auxKC kexts
7
8 def check(kernel_cache):
9 kernel_cache.buildKernelCollection("arm64", "/auxkc-kext-bind-to-kernel-codeless-kext/main.kc", "/auxkc-kext-bind-to-kernel-codeless-kext/main.kernel", "/auxkc-kext-bind-to-kernel-codeless-kext/extensions-basekc", ["com.apple.bar", "com.apple.codeless"], [])
10 kernel_cache.analyze("/auxkc-kext-bind-to-kernel-codeless-kext/main.kc", ["-layout", "-arch", "arm64"])
11
12 assert len(kernel_cache.dictionary()["dylibs"]) == 1
13 assert kernel_cache.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
14
15 # Now build an aux cache using the baseline kernel collection
16 kernel_cache.buildAuxKernelCollection("arm64", "/auxkc-kext-bind-to-kernel-codeless-kext/aux.kc", "/auxkc-kext-bind-to-kernel-codeless-kext/main.kc", "", "/auxkc-kext-bind-to-kernel-codeless-kext/extensions-auxkc", ["com.apple.foo"], [])
17 kernel_cache.analyze("/auxkc-kext-bind-to-kernel-codeless-kext/aux.kc", ["-layout", "-arch", "arm64"])
18
19 # Check the fixups
20 kernel_cache.analyze("/auxkc-kext-bind-to-kernel-codeless-kext/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"
26
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
30