【发布时间】:2019-01-21 12:30:31
【问题描述】:
我在 Linux x64 上使用 Mips 交叉编译器编译简单程序,然后使用 scp 将其上传到我的路由器上。当我运行这个程序时,我有错误:非法指令。
我的程序:
#include <stdio.h>
int main(void)
{
printf("Hello, world!");
return 0;
}
/proc/cpuinfo 我的 mips-box:
system type : Atheros AR9330 rev 1
machine : TP-LINK TL-WR741ND v4
processor : 0
cpu model : MIPS 24Kc V7.4
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16
编译:
mips-linux-gnu-gcc -static -march=24kc -o hello hello.c
上传:
scp hello root@192.168.1.1:/tmp
运行:
root@OpenWrt:/tmp# ./hello
Illegal instruction
【问题讨论】:
-
我高度怀疑标准 C 库(这里是
stdio.h)可以在这种情况下使用。 -
我尝试在没有任何库的情况下编译这个程序。只有 int main(void){}。结果完全一样。@SusmitAgrawal
-
尝试使用
-ffreestanding标志。 -
@SusmitAgrawal 不起作用