修复 xnu 构建后的 kextcache "couldn't find symbol" 错误

Fix kextcache "couldn't find symbol" errors after xnu build

我正在尝试构建 运行 xnu-4570.41.2 kernel for OS X High Sierra 10.13.3. I am locally compiling it according to guides such as ssen's blog and this more recent tutorial。编译内核后,我将其加载到 High Sierra 10.13.3 VirtualBox VM 上,替换那里的内核,以便它从我的内核启动。

尽管 VM 正在启动并且 运行 正在启动我的内核(从我更换内核前后 uname -a 输出的差异以及我添加到启动过程的打印语句中可以看出),我在内核扩展预链接过程中看到以下错误。它们出现在引导过程中以及每当我 运行 sudo kextcache -invalidate / 根据指南的说明用我自己的内核替换 VM 内核后。

kxld[com.apple.iokit.IOStorageFamily]: In interface com.apple.kpi.mach of __kernel__, couldn't find symbol _mach_bridge_register_regwrite_timestamp_callback

kxld[com.apple.iokit.IOStorageFamily]: In interface com.apple.kpi.private of __kernel__, couldn't find symbol _kern_buflet_get_data_length

kxld[com.apple.iokit.IOStorageFamily]: In interface com.apple.kpi.private of __kernel__, couldn't find symbol _kern_buflet_get_data_limit

kxld[com.apple.iokit.IOStorageFamily]: In interface com.apple.kpi.private of __kernel__, couldn't find symbol _kern_buflet_get_data_offset

...

kxld[com.apple.nke.applicationfirewall]: In interface com.apple.kpi.private of __kernel__, couldn't find symbol _xcpm_mbox_lock

kxld[com.apple.nke.applicationfirewall]: In interface com.apple.kpi.private of __kernel__, couldn't find symbol _xcpm_mbox_unlock

kxld[com.apple.nke.applicationfirewall]: In interface com.apple.kpi.bsd of __kernel__, couldn't find symbol _bpf_tap_packet_in

kxld[com.apple.nke.applicationfirewall]: In interface com.apple.kpi.bsd of __kernel__, couldn't find symbol _bpf_tap_packet_out

这些只是大约 18,000 个此类错误中的一部分。虽然这些错误不会阻止构建工作的 PrelinkedKernel,但在内核编译或安装中显然缺少一些步骤。为什么会出现这些错误?有谁知道我该如何解决它们?

基于来自 Open Source Stack Exchange 的 this question 谈论我丢失的一些 xcpm 符号,我得出结论,这些符号丢失是因为它们来自 Apple 没有的专有文件'与 xnu 开源一起发布。

更新:这些丢失的符号错误可以通过在xnu/config/Private.exports中为它们指定声明来解决。通过 kernelshaman's Makefile 构建内核会自动为您添加这些符号。