【发布时间】:2020-08-15 12:23:59
【问题描述】:
我正在准备用户模式 Qemu(qemu-user 包)qemu-arm 的演示。为此,我使用了一个简单的 hello world C 程序hello.c:
#include <stdio.h>
int main()
{
printf("Oi, Qemu!\nPrograma C aqui!\n");
}
为了交叉编译(静态链接),我使用了来自gcc-arm-linux-gnueabihf的交叉工具链:
$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-10ubuntu1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ arm-linux-gnueabihf-gcc hello.c -o hello_c_static -static
输出在 qemu-arm、Beaglebone Black 和 PC 上运行。
这怎么可能?!
编辑
关于编译后的可执行文件:
file hello_c_static
hello_c_static: ELF 32-bit LSB executable, ARM, EABI5 version 1
(GNU/Linux), statically linked,
BuildID[sha1]=6a33aaa5abb9a14fbc0ca4f2e7b432d6fa5d7067, for GNU/Linux 3.2.0,
not stripped
【问题讨论】:
标签: linux x86 arm cross-compiling qemu