本文介绍了ARM编译错误,可执行文件使用VFP寄存器,而不是目标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近几天我一直遇到这个问题,我无法理解这里真正发生的事情或问题所在.

I have been having this problem for the last few days and I can't get my head around what is really happening here, or what is the problem.

我有一个带有以下标志的makefile:

I have a makefile with these flags:

CC = arm-linux-gnueabihf-gcc-4.6
FLAGS = -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -std=gnu99

我在.a文件中有一个库,其中有一些目标文件,我所要做的就是将它们与我的可执行文件链接在一起.我知道原型机以及所有这些,唯一抱怨的是以下内容:

I have a library in a .a file, which has some object files, all I need to do is link them in with my executable. I know the prototypes and all that, the only thing that complains is the following:

/usr/bin/ld: error: *EXECUTABLE* uses VFP register arguments, *OBJECTFILE* does not
/usr/bin/ld: failed to merge target specific data of file *OBJECTFILE*

当我不使用-mfloat-abi = softfp时,会出现另一个与浮点寄存器有关的错误.

When I don't use the -mfloat-abi=softfp, I get another error relating to floating point registers.

有人知道导致这个问题的原因是什么,以及如何解决该问题,例如使它成为可执行文件而不使用虚拟浮点寄存器自变量?

Does anyone have any idea what is causing this, and what I can do to fix this, such as making it so that my executable does not use Virtual Floating Point Register arguments?

x@x:~/Desktop/perf_test$ make
arm-linux-gnueabihf-gcc-4.6 -c -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -ftree-vectorize -std=gnu99 -mfloat-abi=softfp  perf_test.c ../baseline/util.c
arm-linux-gnueabihf-gcc-4.6 -o perf_test perf_test.o util.o  ../baseline/lib.a
/usr/bin/ld: error: perf_test uses VFP register arguments, perf_test.o does not
/usr/bin/ld: failed to merge target specific data of file perf_test.o
/usr/bin/ld: error: perf_test uses VFP register arguments, util.o does not
/usr/bin/ld: failed to merge target specific data of file util.o
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(a.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(a.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(b.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(b.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(c.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(c.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(d.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(d.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(e.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(e.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(f.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(f.o)
collect2: ld returned 1 exit status
make: *** [perf_test] Error 1

推荐答案

您的目标三元组表明您的编译器配置为 hard-float ABI.这意味着libgcc库也将是hardfp.错误消息表明您的系统中至少有一部分正在使用 soft-float ABI.

Your target triplet indicates that your compiler is configured for the hard-float ABI. This means that the libgcc library will also be hardfp. The error message indicates that at least part of your system is using soft-float ABI.

如果编译器启用了multilib(可以用-print-multi-lib告诉),则可以使用-mfloat-abi=softfp,但是如果没有启用,则该选项对您无济于事:gcc会很高兴地生成softfp代码,但随后就可以了.不会是要链接的兼容libgcc.

If the compiler has multilib enabled (you can tell with -print-multi-lib) then you can use -mfloat-abi=softfp, but if not then that option won't help you much: gcc will happily generate softfp code, but then there'll be no compatible libgcc to link against.

基本上,hardfp和softfp不兼容.您需要以一种或另一种方式配置整个系统.

Basically, hardfp and softfp are just not compatible. You need to get your whole system configured one way or the other.

某些发行版是或将是"multiarch".如果您有其中之一,则可以一次安装两个 ABI,但这是通过将所有内容加倍完成的-兼容性问题仍然存在.

some distros are, or will be, "multiarch". If you have one of those then it's possible to install both ABIs at once, but that's done by doubling everything up -- the compatibility issues still exist.

这篇关于ARM编译错误,可执行文件使用VFP寄存器,而不是目标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 13:28