问题描述
这是我的代码,我想在基于cortex-m4 linux的主板(stm32f429)上运行它,但是在此之前,我想使用qemu在我的PC上测试程序。
#include <iostream>
int main()
{
std::cout << "Hello,World!" << std::endl;
return 0;
}
我已使用以下命令编译了该文件:arm-linux-gnueabi-g++ -static -mcpu=cortex-m4 hello.cpp -o hello
,并使用readelf
检查了生成的elf文件,这是输出:
$ readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_cpu_name: "7E-M"
Tag_cpu_arch: v7E-M
Tag_cpu_arch_profile: microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte,except leaf SP
Tag_ABI_enum_size: int
Tag_cpu_unaligned_access: v6
这就是我要模拟的方式:qemu-arm -cpu cortex-m4 hello
但是会引发此错误:
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction
即使我试图在物理板上运行它,我的内核也会抛出error -8
,这是一个ENOEXEC
错误,或者基本上是:Exec format error
我在所有cortex-m cpu上都尝试过,但没有一个起作用(皮质m0,m3,m4,m7)
我的elf文件有什么问题?为什么qemu和我的物理板会抛出此错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)