Skip to content

Instantly share code, notes, and snippets.

@puhitaku
Created March 1, 2023 17:20
Show Gist options
  • Save puhitaku/a7495aff9e56959c02fd1213777023a2 to your computer and use it in GitHub Desktop.
Save puhitaku/a7495aff9e56959c02fd1213777023a2 to your computer and use it in GitHub Desktop.
Register qemu-arm-static to the running Linux kernel
#!/bin/sh
if [ -e /proc/sys/fs/binfmt_misc/qemu-arm ]; then
echo "qemu-arm is already registered to binfmt_misc."
exit 1
fi
# Ref: https://docs.kernel.org/admin-guide/binfmt-misc.html
NAME='qemu-arm'
TYPE='M'
OFFSET='0'
MAGIC='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
MASK='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
INTERPRETER='/usr/bin/qemu-arm-static'
FLAGS='OCF'
echo ":${NAME}:${TYPE}:${OFFSET}:${MAGIC}:${MASK}:${INTERPRETER}:${FLAGS}" > /proc/sys/fs/binfmt_misc/register
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment