import os
import KernelCollection
def check(kernel_cache):
kernel_cache.buildKernelCollection("arm64", "/pageablekc-bind-to-basekc/main.kc", "/pageablekc-bind-to-basekc/main.kernel", "/pageablekc-bind-to-basekc/extensions", ["com.apple.foo"], [])
kernel_cache.analyze("/pageablekc-bind-to-basekc/main.kc", ["-symbols", "-arch", "arm64"])
assert kernel_cache.dictionary()["dylibs"][1]["name"] == "com.apple.foo"
assert kernel_cache.dictionary()["dylibs"][1]["global-symbols"][0]["name"] == "_foo"
assert kernel_cache.dictionary()["dylibs"][1]["global-symbols"][0]["vmAddr"] == "0x10000"
kernel_cache.buildPageableKernelCollection("arm64", "/pageablekc-bind-to-basekc/pageable.kc", "/pageablekc-bind-to-basekc/main.kc", "/pageablekc-bind-to-basekc/extensions", ["com.apple.bar"], [])
kernel_cache.analyze("/pageablekc-bind-to-basekc/pageable.kc", ["-fixups", "-arch", "arm64"])
assert kernel_cache.dictionary()["dylibs"][0]["name"] == "com.apple.bar"
assert len(kernel_cache.dictionary()["dylibs"][0]["fixups"]) == 1
assert kernel_cache.dictionary()["dylibs"][0]["fixups"]["0xC000"] == "kc(0) + 0x10000"