cpu: arm-926jes
平台:at91sam9g25ek
编译最新的uboot 2015.01,用到的toolchain,是arm2007q1,gcc的版本是4.20
arm-none-linux-gnueabi-ld: ERROR: Source object arch/arm/cpu/built-in.o has EABI version 0, but target u-boot has EABI version 4 arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/cpu/built-in.o
网上搜的原因,有这么个说法:
This is a simple problem to fix. First you need to understand that the ARM EABI and ARM GNU/Linux toolchains are different. The Linux kernel and applications are compiled with ARM GNU/Linux toolchain, while bootloaders are compiled with ARM EABI toolchain. U-boot is a bare-metal application, therefore use the ARM EABI toolchain. That is the best way to compile U-boot and other non-Linux applications. It is possible to compile U-boot with Linux toolchain but not recommended.
ARM EABI 和 gnu/linux的工具链是不同的。内核和应用的编译工具是 GNU/linux的,而bootloader是用的ARM EABI方式的。
U-boot的就是裸二进制bin文件,因此用ARM EABI。这种工具链是编译uboot及其其他非linux可执行程序的最好方式。可能的话,用Linux的工具链来编译uboot。只是这种方式不建议使用。
个人总结:很不幸,我就是一直用的这种工具编译的uboot,包括boostrap。之前编译以前的代码没有出现过问题,因此怀疑此uboot源码,在编译选项上有一些差异,是导致此次编译不过的原因。
另外,找到一篇这种解释:
Question: When trying to build U-Boot with an EABI compliant tool chain, I get such error messages: arm-ld: ERROR: Source object ... has EABI version 4, but target ... has EABI version 0 What does that mean, and how can I fix that? Answer: "EABI version 0" means the "apcs-gnu" ABI, while "EABI version 4" is the "aapcs-linux" ABI, aka "gnueabi". All U-Boot ARM sources are built with "-mapcs-gnu" option set in "cpu/arm/config.mk", while libgcc.a modules are built in "gnueabi" format, which is for example the ARM GCC default in ELDK Release 4.2. So the real problem is compatibility between toolchain ABI and U-Boot ARM ABI. In the Linux kernel there is a special kernel config option for EABI-enabled tool chains (CONFIG_AEABI), which enables special pieces of code in ARM assembler modules. We could follow this approach, reworking existing assembler sources and respective config.mk files in U-Boot. Alternatively, the tool chain could provide a separate version of libgcc.a built with old ABI. This could be done using the multilib approach. The advantage here is that no U-boot changes will be required.
简单翻译:
1.为什么编译uboot的时候,提示“EABI 4,。。。。but EABI 0”(注:和我的问题差不多)
答:"EABI version 0"的意思是编译选项用 “apcs-gnu” ,"version 4"用 “aapcs-linux”也可以用 “gnueabi”
所有的uboot 的arm体系源码代码,用选项“-mapcs-gnu”进行编译,选项配置位于 cpu/arm/config.mk文件中,但是,libgcc.a模块使以 gnueabi的格式建立,并且默认的ARM GCC编译版本为 ELDK发布版4.2.0.
所以,问题的关键是兼容性问题。是gnu/linux ABI 和uboot ARM ABI之间的兼容性问题。在linux内核中,有一个特殊的内核配置选项,使能EABI工具链(CONFIG_AEBI),它能促使一部分关乎ARM汇编模块的代码被编译到内核。我们可以这么做,重新编写或者修改汇编源码和config.mk文件。
另外的方法,就是工具链可以提供一种分离的libgcc.a来建立OABI。这种方法的优点就是不用修改uboot源码而已。
说了这么多,说说自己解决的过程:
1.修改arch/arm/config.mk
# -mapcs-32 PF_CPPFLAGS_ABI := $(call cc-option,\ -mabi=aapcs-linux,\ $(call cc-option,\ -mapcs-32,\ $(call cc-option,\ -mabi=apcs-gnu,\ )\ )\ ) PF_CPPFLAGS_ABI := -mabi=apcs-gnu -mfpu=fpa #添加这么一句,其实就是把上一句的选项判断给屏蔽了而已 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI)
LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \ -fno-common -ffixed-r9 #PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) #将此行屏蔽 不使用软浮点 PLATFORM_RELFLAGS += $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))#变更到只保留这行为什么要这么做????
因为不做第二步,再次编译会出现下面的问题。其实,是一个浮点数运算的问题,是用硬件浮点还是软件模拟。
arm-none-linux-gnueabi-ld: ERROR: arch/arm/cpu/built-in.o uses FPA instructions, whereas u-boot does not arm-none-linux-gnueabi-ld: ERROR: arch/arm/cpu/built-in.o uses hardware FP, whereas u-boot uses software FP arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/cpu/built-in.o
转载一篇文章关于EABI OABI的区别
1。什么是ABI
ABI,application binary interface (ABI),应用程序二进制接口。
既然是 接口,那就是某两种东西之间的沟通桥梁,此处有这些种情况:
A。应用程序 <-> 操作系统;
B。应用程序 <-> (应用程序所用到的)库
C 。应用程序各个组件之间
类似于API的作用是使得程序的代码间的兼容,ABI目的是使得程序的二进制(级别)的兼容。
2。什么是OABI 和 EABI
OABI中的O,表示“Old”,“Lagacy”,旧的,过时的,OABI就是旧的/老的ABI。
EABI中的E,表示“Embedded”,是一种新的ABI。
EABI有时候也叫做GNU EABI。
OABI和EABI都是专门针对ARM的CPU来说的。
3。EABI的好处 / 为何要用EABI
A。支持软件浮点和硬件实现浮点功能混用
B。系统调用的效率更高
C。和今后的工具更兼容
D。软件浮点的情况下,EABI的软件浮点的效率要比OABI高很多。
4。OABI和EABI的区别
两种ABI在如下方面有区别:
A。调用规则(包括参数如何传递及如何获得返回值)
B。系统调用的数目以及应用程序应该如何去做系统调用
C。目标文件的二进制格式,程序库等
D。结构体中的 填充(padding/packing)和对齐。
E。
OABI:
* ABI flags passed to binutils: -mabi=apcs-gnu -mfpu=fpa
* gcc -dumpmachine: arm-unknown-linux
* objdump -x for compiled binary:
* "file" on compiled Debian binary:
* "readelf -h | grep Flags""
EABI:
* ABI flags passed by gcc to binutils: -mabi=aapcs-linux -mfloat-abi=soft -meabi=4
* gcc -dumpmachine: arm-unknown-linux-gnueabi
* objdump -x for compiled binary:
* "file" on compiled binary (under Debian):
* "readelf -h | grep Flags""
【如何查看当前的库文件或者目标文件是EABI还是OABI】
可以通过readelf -h查看:
[crifan@linux-41lh bch]$readelf -h a_eabi_object.obj
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX – System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 42880 (bytes into file)
Flags: 0x4000000, Version4 EABI
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 12
Section header string table index: 9
[crifan@linux-41lh bch]$readelf -h a_oabi_object.obj
ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 46400 (bytes into file)
Flags: 0x200, GNU EABI, software FP
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 24
Section header string table index: 21
【提示】
常见遇到的一些问题,我所知道的是,对于OABI的交叉编译器,比如arm-linux-gcc这一套工具,如果你当初是用oabi编译的,那么生成的整套工具链,也是oabi的,用oabi的工具链去编译和链接其他eabi的库,就会出问题,常常是在ld的时候,提示类似如下错误:
arm-linux-ld: error: Source object drivers/mtd/bch/bch_4_s_noRomtable.obj has EABI version 0, but target drivers/mtd/built-in.o has EABI version 4
其解决办法就是,用同一套去编译不同的文件和链接不同的库,比如都是用OABI或者都是用EABI,比如重新去编译一个EABI的交叉工具链,然后用这个EABI的工具链去编译你其他的文件。
【参考】
1。ABI/EABI/OABI
http://blog.csdn.net/hongjiujing/archive/2008/07/21/2686556.aspx
2。Why ARM's EABI Matters
http://www.chineselinuxuniversity.net/articles/1255.shtml
3.[PDF]The new arm ABI (EABI) and Debian armel port
下载此文件 (29 个页面)
4ArmEabiPort
http://wiki.debian.org/ArmEabiPort
http://www.crifan.com/order_eabi_and_oabi/
http://www.denx.de/wiki/DULG/SourceObjectHasEABIVersion4ButTargetHasEABIVersion0