Running ARM Applications on Native Linux

Leave a Comment
Today I’ve got a Linux application running on aarch64 architecture. But I don’t have any aarch64 (ARM64) architecture devices. So I’ve found a way to run it on my native Linux (without VM).
QEMU is a generic and open source machine emulator and virtualizer. Thanks to QEMU, we can running almost any other architecture applications on your native Linux host.

As for ARM (Arch Linux):

Preparetion: You need installing some packages first.
QEMU
Glibc(runtime)
GCC(for compiling)
GDB(for debug)
extra/qemu 2.4.1-2 [installed]    
    A generic and open source processor emulator which achieves a good emulation speed by using dynamic translation
extra/qemu-arch-extra 2.4.1-2 [installed]
    QEMU with full support for non x86 architectures
aur/qemu-user-static 2.5-2 [installed: 2.5-3] (31)
    A generic and open source processor emulator which achieves a good emulation speed by
community/arm-none-eabi-binutils 2.25.1-2 [installed]
    A set of programs to assemble and manipulate binary and object files for the ARM EABI
    (bare-metal) target
community/arm-none-eabi-gcc 5.3.0-1 [installed]
    The GNU Compiler Collection - cross compiler for ARM EABI (bare-metal) target
community/arm-none-eabi-gdb 7.10.1-1
    The GNU Debugger for the ARM EABI (bare-metal) target
community/arm-none-eabi-newlib 2.3.0.20160104-1 [installed]
    A C standard library implementation intended for use on embedded systems (ARM bare metal)

Now for aarch64 (Arch Linux):

Preparetion: You need some packages.
QEMU
Glibc(runtime)
GCC(for compiling)
GDB(for debug)
All aarch64 specific packages are in AUR:
aur/aarch64-linux-gnu-binutils 2.25.1-1 [installed] (1)
    A set of programs to assemble and manipulate binary and object files for the ARM64 target
aur/aarch64-linux-gnu-eglibc 2.19.r25988-1 [installed] (0)
    Embedded GNU C Library (aarch64-linux-gnu)
aur/aarch64-linux-gnu-eglibc-headers 2.19.r25988-1 (0)
    Embedded GNU C Library. Stage 1 - headers only. Needed for initialy build toolchain (aarch64-linux-gnu)
aur/aarch64-linux-gnu-gcc 5.3.0-1 [installed] (2)
    The GNU Compiler Collection - cross compiler for ARM64 target
aur/aarch64-linux-gnu-gcc-stage1 5.3.0-1 (0)
    The GNU Compiler Collection - cross compiler for ARM64 target
aur/aarch64-linux-gnu-gcc-stage2 5.3.0-1 (0)
    The GNU Compiler Collection - cross compiler for ARM64 target
aur/aarch64-linux-gnu-gdb 7.10.1-1 [installed] (0)
    The GNU Debugger for the ARM64 target
aur/aarch64-linux-gnu-linux-api-headers 4.4-1 [installed] (0)
    Kernel headers sanitized for use in userspace (aarch64-linux-gnu)
You don’t need to install aarch64-linux-gnu-gcc-stage1 or aarch64-linux-gnu-gcc-stage2 for they are temporary used to build gcc.

Attetion:

To find library location, just type “pacman -Ql aarch64-linux-gnu-eglibc”, and using “qemu-aarch64 -L /usr/aarch64-linux-gnu” specify library location, and “-g port” for gdb debuging.

Other resources:

  • http://www.bennee.com/~alex/blog/2014/05/09/running-linux-in-qemus-aarch64-system-emulation-mode/
  • https://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/
  • https://gist.github.com/shiliang-hust/acf3e1294f1f04ef0eb6
  • https://reverseengineering.stackexchange.com/questions/8829/cross-debugging-for-mips-elf-with-qemu-toolchain
  • 0 comments:

    Post a Comment