我的二进制文件编译了 https://developer.arm.com/-/media/media/files/downloads/gnu-a/gnu-a/10.3-2021.07/binrel/binrel/gcc-arm-arm-10.3 -2021.07-x86_64-arm-none-eabi.tar.xz ,
带有链接标志:
-lstdc++ -Wl,-z,relro,-z,now -pass-exit-codes -lm -Wall '--specs=rdimon.specs' -lrdimon '-mcpu=cortex-a72.cortex-a53' -mthumb -static
成功编译,但是当我在OpenWrt路由器上执行此文件时,它说:
分段故障。。
我认为也可以在Linux系统上执行裸机二进制,它与任何OS没有任何关系,而与CPU模型没有任何关系。我对吗?
仅供参考:
我的芯片型号是Rockchip 3389,ARMV8,4 Cortex-A72 Core和2 Cortex-A53 Core,在AARCH64模式下运行
my binary file compiled use toolchain from https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi.tar.xz,
with link flag:
-lstdc++ -Wl,-z,relro,-z,now -pass-exit-codes -lm -Wall '--specs=rdimon.specs' -lrdimon '-mcpu=cortex-a72.cortex-a53' -mthumb -static
compiled successfully, but when I execute this file on my openwrt router, it said:
Segmentation fault.
I think a bare-metal binary can also be executed on a linux system, it doesn't have any relationships with any os, only with a cpu model. Am I right?
FYI:
my chip model was rockchip 3389, armv8, 4 cortex-a72 core and 2 cortex-a53 core, run under aarch64 mode
发布评论
评论(1)
我认为也可以在Linux系统上执行裸机二进制,它与任何OS没有任何关系,而仅与CPU模型。我是吗?
不,你不是。
如果您的SOC具有A72和A53内核,则您不会使用正确的编译器:如果您为其编写裸机程序,则必须使用工具链,而不是 arm-none-eabi 一个,
OpenWrt是一个Linux操作系统:在
glibc
-基于linux系统,您将使用 aarch64-none-none-linux-gnu 工具链,但是当针对musl-libc
基于基于的系统时,例如,您应该使用a aarch64-linux-musl toolchain。 P>I think a bare-metal binary can also be executed on a linux system, it doesn't have any relationships with any os, only with a cpu model. Am I right?
No, you are not.
If your SoC has A72 and A53 cores, you are not using the right compiler: if you were writing bare-metal programs for it, you would have to use the aarch64-none-elf toolchain, and not the arm-none-eabi one,
OpenWRT is a Linux operating system: on a
glibc
-based Linux system, you would use the aarch64-none-linux-gnu toolchain, but when targeting amusl-libc
-based system, you should for example use a aarch64-linux-musl toolchain.