Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

tools/init: test init opens /dev/console, writes a line, exits 42 (errno-coded exits on failure); vm-install.sh builds it into root.img

Heyang Zhou90b9f271c637
diff --git a/tools/init/vm-install.sh b/tools/init/vm-install.sh
new file mode 100755
index 0000000..0d8ed4a
--- /dev/null
+++ b/tools/init/vm-install.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# In the VM: build tools/init with the DroidVM k27 toolchain and put it at /sbin/launchd in /lib/firmware/xnu/root.img.
+set -euo pipefail
+cd "$(dirname "$0")"; TC=~/w/dvm/toolchains/linux/bin26
+$TC/target-clang -target arm64-apple-macos14.0 -c start.s -o start.o
+$TC/target-clang -target arm64-apple-macos14.0 -nostdlib -static -e _start -Wl,-adhoc_codesign start.o -o init
+cp /lib/firmware/xnu/root.img /tmp/root.img; sudo mkdir -p /mnt/rd
+sudo mount -o loop -t hfsplus /tmp/root.img /mnt/rd
+sudo cp init /mnt/rd/sbin/launchd; sudo chmod 755 /mnt/rd/sbin/launchd; ls -la /mnt/rd/sbin /mnt/rd/dev
+sudo umount /mnt/rd; sudo cp /tmp/root.img /lib/firmware/xnu/root.img