]> git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/auxkc-kext-bind-to-pageablekc-codeless-kext/test.py
dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / auxkc-kext-bind-to-pageablekc-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 pageableKC, but can be a dependency for auxKC kexts
7
8 def check(kernel_cache):
9 kernel_cache.buildKernelCollection("arm64", "/auxkc-kext-bind-to-pageablekc-codeless-kext/main.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/main.kernel", None, [], [])
10 kernel_cache.analyze("/auxkc-kext-bind-to-pageablekc-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 pageable cache using the baseline kernel collection
16 kernel_cache.buildPageableKernelCollection("arm64", "/auxkc-kext-bind-to-pageablekc-codeless-kext/pageable.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/main.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/extensions-pageablekc", ["com.apple.bar", "com.apple.codeless"], [])
17 kernel_cache.analyze("/auxkc-kext-bind-to-pageablekc-codeless-kext/pageable.kc", ["-layout", "-arch", "arm64"])
18
19 assert len(kernel_cache.dictionary()["dylibs"]) == 1
20 assert kernel_cache.dictionary()["dylibs"][0]["name"] == "com.apple.bar"
21
22 # Now build an aux cache using the baseline kernel collection
23 kernel_cache.buildAuxKernelCollection("arm64", "/auxkc-kext-bind-to-pageablekc-codeless-kext/aux.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/main.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/pageable.kc", "/auxkc-kext-bind-to-pageablekc-codeless-kext/extensions-auxkc", ["com.apple.foo"], [])
24 kernel_cache.analyze("/auxkc-kext-bind-to-pageablekc-codeless-kext/aux.kc", ["-layout", "-arch", "arm64"])
25
26 # Check the fixups
27 kernel_cache.analyze("/auxkc-kext-bind-to-pageablekc-codeless-kext/aux.kc", ["-fixups", "-arch", "arm64"])
28 assert len(kernel_cache.dictionary()["fixups"]) == 1
29 assert kernel_cache.dictionary()["fixups"]["0x4000"] == "kc(1) + 0x8000"
30 assert len(kernel_cache.dictionary()["dylibs"]) == 1
31 assert kernel_cache.dictionary()["dylibs"][0]["name"] == "com.apple.foo"
32 assert kernel_cache.dictionary()["dylibs"][0]["fixups"] == "none"
33
34 # [~]> xcrun -sdk iphoneos 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
35 # [~]> xcrun -sdk iphoneos cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-no_data_const foo.c -o extensions-auxkc/foo.kext/foo
36 # [~]> xcrun -sdk iphoneos cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info -Wl,-no_data_const bar.c -o extensions-pageablekc/bar.kext/bar
37 # [~]> rm -r extensions-*/*.kext/*.ld