]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/kext-weak-bind-chained/test.py
4 import KernelCollection
6 # This verifies that weak binds point to the same symbol
8 # FIXME: This should be re-enabled once we know how to handle classic relocs combined with split seg v2.
10 def check(kernel_cache
):
11 kernel_cache
.buildKernelCollection("arm64", "/kext-weak-bind-chained/main.kc", "/kext-weak-bind-chained/main.kernel", "/kext-weak-bind-chained/extensions", ["com.apple.foo", "com.apple.bar"], [])
12 kernel_cache
.analyze("/kext-weak-bind-chained/main.kc", ["-layout", "-arch", "arm64"])
14 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
15 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
16 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
17 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
20 kernel_cache
.analyze("/kext-weak-bind-chained/main.kc", ["-fixups", "-arch", "arm64"])
21 assert len(kernel_cache
.dictionary()["fixups"]) == 2
22 assert kernel_cache
.dictionary()["fixups"]["0x1C000"] == "kc(0) + 0x1C018"
23 assert kernel_cache
.dictionary()["fixups"]["0x1C010"] == "kc(0) + 0x1C018"
24 assert len(kernel_cache
.dictionary()["dylibs"]) == 3
25 assert kernel_cache
.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
26 assert kernel_cache
.dictionary()["dylibs"][0]["fixups"] == "none"
27 assert kernel_cache
.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
28 assert kernel_cache
.dictionary()["dylibs"][1]["fixups"] == "none"
29 assert kernel_cache
.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
30 assert kernel_cache
.dictionary()["dylibs"][2]["fixups"] == "none"
33 # [~]> 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
34 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info foo.c -o extensions/foo.kext/foo -Wl,-fixup_chains
35 # [~]> xcrun -sdk iphoneos.internal cc -arch arm64 -Wl,-kext -mkernel -nostdlib -Wl,-add_split_seg_info bar.c -o extensions/bar.kext/bar -Wl,-fixup_chains
36 # [~]> rm -r extensions/*.kext/*.ld