GCC編譯器差別

下載了一個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: armmipsx86i686...
  • vendor is tool chain supplier: apple,
  • os is for operating system: linuxnone (bare metal)
  • abi is for application binary interface convention: eabignueabignueabihf
    • the eabi stands for the compilation of code which will run on bare metal arm core.
    • the gnueabi stands for the compilation of code for linux

arm-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提供的編譯器等等,由於這些價格都比較昂貴,不適合學習用戶使用,因此不作講述。

  • arm-none-linux-gnueabi-gcc:是 Codesourcery 公司(目前已經被Mentor收購)基於GCC推出的的ARM交叉編譯工具。可用於交叉編譯ARM(32位)系統中全部環節的代碼,包括裸機程序、u-boot、Linux kernel、filesystem和App應用程序。
  • arm-linux-gnueabihf-gcc:是由 Linaro 公司基於GCC推出的的ARM交叉編譯工具。可用於交叉編譯ARM(32位)系統中全部環節的代碼,包括裸機程序、u-boot、Linux kernel、filesystem和App應用程序。
  • aarch64-linux-gnu-gcc:是由 Linaro 公司基於GCC推出的的ARM交叉編譯工具。可用於交叉編譯ARMv8 64位目標中的裸機程序、u-boot、Linux kernel、filesystem和App應用程序。
  • arm-none-elf-gcc:是 Codesourcery 公司(目前已經被Mentor收購)基於GCC推出的的ARM交叉編譯工具。可用於交叉編譯ARM MCU(32位)芯片,如ARM七、ARM九、Cortex-M/R芯片程序。
  • arm-none-eabi-gcc:是 GNU 推出的的ARM交叉編譯工具。可用於交叉編譯ARM MCU(32位)芯片,如ARM七、ARM九、Cortex-M/R芯片程序。

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:

Latest Linux Targeted Binary Toolchain Releases

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

Latest Bare-Metal Targeted Binary Toolchain Releases

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
相關文章
相關標籤/搜索