]> git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/kext-bind-to-kext-symbol-set-error/test.py
dyld-851.27.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / kext-bind-to-kext-symbol-set-error / test.py
1 #!/usr/bin/python2.7
2
3 import os
4 import KernelCollection
5
6 # This verifies that an non-Apple kext cannot bind to another Apple kext with a symbol set in the kext
7 # foo.kext exports foo and bar.kext uses it
8
9 def check(kernel_cache):
10 kernel_cache.buildKernelCollection("arm64", "/kext-bind-to-kext-symbol-set-error/main.kc", "/kext-bind-to-kext-symbol-set-error/main.kernel", "/kext-bind-to-kext-symbol-set-error/extensions", ["com.apple.foo", "not.com.apple.bar"], ["-json-errors"])
11
12 assert len(kernel_cache.dictionary()) == 1
13 assert kernel_cache.dictionary()[0]["id"] == "not.com.apple.bar"
14 assert len(kernel_cache.dictionary()[0]["errors"]) == 1
15 assert kernel_cache.dictionary()[0]["errors"][0] == "Failed to bind '_foo' in 'not.com.apple.bar' (at offset 0x0 in __DATA, __got) as could not find a kext which exports this symbol"
16
17
18 # [~]> 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
19 # [~]> 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 -Wl,-sectcreate,__LINKINFO,__symbolsets,SymbolSets.plist -Wl,-segprot,__LINKINFO,r--,r--
20 # [~]> 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
21 # [~]> rm -r extensions/*.kext/*.ld
22