热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

u-boot2015.01:hasEABIversion0,buttargetu-boothasEABIversion4

简介cpu:arm-926jes平台:at91sam9g25ek编译最新的uboot2015.01,用到的toolchain,是arm2007q1,gcc的版本是4.20
简介

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:

private flags = 2: [APCS-32] [FPA float format] [has entry point]

* "file" on compiled Debian binary:

ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), for GNU/Linux 2.2.0, stripped

* "readelf -h | grep Flags""

Flags: 0x0

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:

private flags = 4000002: [Version4 EABI] [has entry point]

* "file" on compiled binary (under Debian):

ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses shared libs), for GNU/Linux 2.4.17, stripped

* "readelf -h | grep Flags""

Flags: 0x4000002, has entry point, Version4 EABI

【如何查看当前的库文件或者目标文件是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





推荐阅读
  • 三、查看Linux版本查看系统版本信息的命令:lsb_release-a[root@localhost~]#lsb_release-aLSBVersion::co ... [详细]
  • 【技术分享】一个 ELF 蠕虫分析
    【技术分享】一个 ELF 蠕虫分析 ... [详细]
  • linux下编译安装lnmp
    2019独角兽企业重金招聘Python工程师标准#######################安装依赖#####################安装必要的包:y ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • Android Studio Bumblebee | 2021.1.1(大黄蜂版本使用介绍)
    本文介绍了Android Studio Bumblebee | 2021.1.1(大黄蜂版本)的使用方法和相关知识,包括Gradle的介绍、设备管理器的配置、无线调试、新版本问题等内容。同时还提供了更新版本的下载地址和启动页面截图。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • Android源码深入理解JNI技术的概述和应用
    本文介绍了Android源码中的JNI技术,包括概述和应用。JNI是Java Native Interface的缩写,是一种技术,可以实现Java程序调用Native语言写的函数,以及Native程序调用Java层的函数。在Android平台上,JNI充当了连接Java世界和Native世界的桥梁。本文通过分析Android源码中的相关文件和位置,深入探讨了JNI技术在Android开发中的重要性和应用场景。 ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • 本文介绍了在Android Studio中使用命令行build gradle的方法,并解决了一些常见问题,包括手动配置gradle环境变量和解决External Native Build Issues的方法。同时提供了相关参考文章链接。 ... [详细]
  • Mono为何能跨平台
    概念JIT编译(JITcompilation),运行时需要代码时,将Microsoft中间语言(MSIL)转换为机器码的编译。CLR(CommonLa ... [详细]
  • 原文地址http://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/最开始时 ... [详细]
  • Howtobuilda./configure&&make&&makeins ... [详细]
  • linux 字符串数组初始化,C++字符数组初始化方法的分析
    发现了一个字符数组初始化的误区,而这个往往能导致比较严重的性能问题,分析介绍如下:往往我们在初始化一个字符数组,大概有如下几 ... [详细]
author-avatar
手机用户2502911563
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有