下载了一个arm的gcc编译器遇到编译错误linux
arm-none-eabi/lib/libc.a(lib_a-abort.o): In function `abort': abort.c:(.text+0x10): undefined reference to `_exit' /arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_kill_r': signalr.c:(.text+0x1c): undefined reference to `_kill'
看了手册发现须要设置一个编译选项 --specs=nosys.specs,此次的确编译成功了,可是在Linux系统上运行却SegmentFault。
因而又看了手册发现这个编译器用的时newlib的C库。而linux上的时glibc。同时调用约定和库应该也是不同的。
原来从arm官网上下载的这个时针对裸版的编译器,没有libc,确定运行不起来。须要下载
arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2这样的编译器
这个编译器的目录下面有个libc的目录
https://stackoverflow.com/questions/13797693/what-is-the-difference-between-arm-linux-gcc-and-arm-none-linux-gnueabi/13798214app
Toolchains have a loose name convention like arch[-vendor][-os]-abi
.ide
arch
is for architecture: arm, mips, x86, i686...vendor
is tool chain supplier: apple,os
is for operating system: linux, none (bare metal)abi
is for application binary interface convention: eabi, gnueabi, gnueabihfarm-none-linux-gnueabi
and arm-linux-gnueabi
is same thing. arm-linux-gcc
is actually binary for gcc which produces objects for ARM architecture to be run on Linux with default configuration (abi) provided by toolchain.工具
例如 https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads 下载的学习
gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2 目的是给arm的裸版编译程序使用的,它只是linux上的一种安装包,所以编译出来的程序没法在linux上运行网站
而若是要能够在linux上运行须要使用gnueabi的编译器。this
而编译内核和uboot两种编译器均可以用spa
When compiling .c into .o, the ABI you choose affects which registers are used for parameters, stack-layout etc. When linking the .o into an executable, the ABI have a default linker script and helper objects. But both the kernel and probably u-boot provides their own linker scripts etc, so the ABI for this step is not so importantcode
http://www.veryarm.com/cross-toolscomponent
免费版目前有三大主流工具商提供,第一是GNU(提供源码,自行编译制做),第二是 Codesourcery,第三是Linora。
收费版有ARM原厂提供的armcc、IAR提供的编译器等等,由于这些价格都比较昂贵,不适合学习用户使用,因此不作讲述。
The bare-metal ABI (eabi) will assume a different C library (newlib for example, or even no C library) to the Linux ABI (gnueabi, which assumes glibc). Therefore, the compiler may make different function calls depending on what it believes is available above and beyond the Standard C library
例如在https://www.linaro.org/downloads/ 网站上有linux和裸版两种编译器的下载
The following tables provide direct access to the most common Linux and bare-metal ABI variants of the Linaro binary cross-toolchain quarterly releases. Both x86_64 Linux and Mingw32 (MS Windows compatible) host binaries are provided:
arm-linux-gnueabihf | 32-bit ARMv7 Cortex-A, hard-float, little-endian | Release-Notes | Binaries | Source |
armv8l-linux-gnueabihf | 32-bit ARMv8 Cortex-A, hard-float, little-endian | Release-Notes | Binaries | Source |
aarch64-linux-gnu | 64-bit ARMv8 Cortex-A, little-endian | Release-Notes | Binaries | Source |
arm-eabi | 32-bit ARMv7 Cortex-A, soft-float, little-endian | Release-Notes | Binaries | Source |
aarch64-elf | 64-bit ARMv8 Cortex-A, little-endian | Release-Notes | Binaries | Source |