macosmacos-high-sierrakernel-extensiondarwinxnu

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


I am trying to build and run an 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. Once I compile the kernel, I load it onto a High Sierra 10.13.3 VirtualBox VM, replacing the kernel there so that it boots from my kernel instead.

Although the VM is booting and running my kernel (discernible from differences in uname -a output before and after I replace the kernel as well as print statements I add to the boot process), I am seeing the following errors during the kernel extension prelinking process. They appear during the boot process and whenever I run sudo kextcache -invalidate / after replacing the VM's kernel with my own per the guides' instructions.

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

These are just a sampling of the some 18,000 such errors. While these errors don't prevent a working PrelinkedKernel from being built, there is clearly some missing step in the kernel compilation or installation. Why might these errors occur? Does anyone know how I can resolve them?


Solution

  • Based on this question from Open Source Stack Exchange talking about some of the xcpm symbols I'm missing, I've concluded that these symbols are missing because they are from proprietary files Apple doesn't release with the xnu open-source.

    Update: These missing symbols errors can be resolved by specifying declarations for them in xnu/config/Private.exports. Building the kernel via kernelshaman's Makefile adds these symbols in for you automatically.