joe 发表于 2022-8-3 09:25:35

基于 QEMU USER MODE 运行 AARCH64 程序

工具准备
aarch64-linux-gnu-gcc:可以通过下载 linaro 工具链
qemu-aarch64
程序范例
aarch64 汇编
创建文件asm64.S,其内容如下

.section .text
.global _start

_start:
      /* syscall write(int fd, const void *buf, size_t count) */
      mov x0, #1
      ldr x1, =msg
      ldr x2, =len
      mov w8, #64
      svc #0

      /* syscall exit(int status) */
      mov x0, #0
      mov w8, #93
      svc #0

msg:
      .ascii "Hello, ARM64!\n"
      len = . - msg
然后编译并使用 qemu 虚拟机运行

$ aarch64-linux-gnu-gcc -nostdlib -nodefaultlibs -o asm64 asm64.S
$ qemu-aarch64 ./asm64
aarch64 C语言
创建文件hello64.c,其内容如下

#include <stdio.h>

int main(int argc, char *argv)
{
      printf("Hello, I'm executing ARM64 instructions\n");

      return 0;
}
然后编译并使用 qemu 运行

$ aarch64-linux-gnu-gcc -static -o hello64 hello64.c
$ qemu-aarch64 ./hello64
参考
arm-on-x86-qemu-user
本文来自博客园,作者:Legend_Lone,转载请注明原文链接:https://www.cnblogs.com/sun-ye/p/14992339.html

页: [1]
查看完整版本: 基于 QEMU USER MODE 运行 AARCH64 程序