vendredi 18 avril 2014

Run Aarch64 (ARMv8) binaries under x86 box

A small post to explain how to run ARM binaries on an x86 linux box.
mitsurugi@mitsu:~$ uname -a
Linux mitsu 3.10.17 #2 SMP Wed Oct 23 16:34:38 CDT 2013 x86_64 Intel(R) Core(TM)2 CPU         U7600  @ 1.20GHz GenuineIntel GNU/Linux

Ok. Just download the debian tgz (88MB) and static qemu binary (~7MB) from the page:
http://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/

Untar the tgz under /chroot_armv8, copy the qemu-arm-static binary under /chroot_armv8.

Then tell your kernel to use qemu for ARM binary. Read https://www.kernel.org/doc/Documentation/binfmt_misc.txt for more information about binfmt_misc.

mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 
cd /proc/sys/fs/binfmt_misc 
echo ":qemu-arm64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-arm64-static:OC" > register 
cd /chroot_armv8
chroot .
root@mitsu:/# uname -a
Linux mitsu 3.8.0 #2 SMP Wed Oct 23 16:34:38 CDT 2013 aarch64 GNU/Linux

And now, you're in a debian ARMv8 :-) You can eventually bind mount some directories like /proc, /sys, etc. but at first:

echo "8.8.8.8 nameserver" > /etc/resolv.conf
apt-get update


and it's OK to start with your brand new ARMv8 board!

[update1] : rename qemu-arm-static in binfmt
[update2] : No, you can'use gdb with this setup. Qemu-arm-static doesn't seems to send ptrace syscalls. You have to use qemu with integrated gdb server and use a gdb multiarch

Aucun commentaire:

Enregistrer un commentaire