关于在编制ARM目标应用程序使用的浮点ABI标志 [英] Regarding the floating point abi flag used while compiling an application for arm target

查看:405
本文介绍了关于在编制ARM目标应用程序使用的浮点ABI标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近写C应用程序为ARM目标。为了交叉编译为ARM目标的应用程序,有一个标志 -mfloat-ABI =硬,必须予以使用。但我实际上并没有明白是什么意思。是否有人可以解释标志的意思。编译应用程序时,它会做出什么改变?

I have recently written c applications for the arm target. In order to cross compile an application for the arm target, there was a flag -mfloat-abi=hard that had to be used. But I didn't actually understand what it means. Can someone please explain what the flag means. What changes will it make when compiling the application?

推荐答案

的区别在于调用约定。 ARM采用基于寄存器的调用约定,其中两个参数的函数(达到了一个极限,之后他们开始溢出到堆栈),和返回值,在寄存器传递(为全血淋淋的细节,请参见过程调用标准的)。当涉及到浮点值,则presence与否的硬件协处理器FPU在提出如何处理浮点值略有难题,使两种可能性产生code时:

The difference lies in the calling convention. ARM uses register-based calling conventions, in which both the arguments to a function (up to a limit, after which they start spilling to the stack), and the return value, are passed in registers (for the full gory details, see the Procedure Call Standard). When it comes to floating-point values, the presence or not of a hardware FPU coprocessor raises a slight conundrum over how to deal with floating point values, giving two possibilities when generating code:


  • 硬浮动:您认为浮点硬件的<​​em>是的present和FP参数和返回值在FPU寄存器传递。这是更有效的,当你的的有FPU,而不是移植到机器无一物,何处的code将炸毁试图访问不存在的寄存器。

  • Hard-float: you assume that floating point hardware is present, and FP arguments and return values are passed in FPU registers. It's more efficient when you do have an FPU, but is not portable to machines without one, where the code would blow up trying to access registers that don't exist.

软浮动:浮点参数传递的通用寄存器相同的方式32位或64位的整数会。被叫功能然后将它们转移到FPU寄存器来完成它的工作,如果有硬件支持,如果没有回落到浮点仿真。因此,你的code可以与合适的库支持在任何地方工作,在一个很小的开销甚至真正的FPU硬件(这可能会成为微不足道的功能更显著)的成本。

Soft-float: floating-point arguments are passed in general-purpose registers the same way 32-bit or 64-bit integers would be. The callee function can then transfer them into FPU registers to do its work if it has hardware support, or fall back to floating-point emulation if not. Thus your code can work anywhere with the right library support, at the cost of a slight overhead even on real FPU hardware (which may become more significant for trivial functions).

从这里,你大概可以推断whay你不能将两者搅和 - 说你的可能的编译函数调用作为软浮动,但链接到实现该功能的硬浮库 - 您的电话code可能把一个float参数在 R1 ,但被叫方code将寻找它在 S0 并继续计算与任何垃圾废话的价值在那里。同样,库函数随后将返回 S0 A float结果,但你的code将与任何发生在 R0要留给流失键,更加错误的。

From that, you can probably deduce whay you can't mix the two - say you could compile a function call as soft-float, but link to a hard-float library implementing that function - your calling code might put a float argument in r1, but the callee code will look for it in s0 and proceed to calculate nonsense with whatever garbage value was in there. Similarly, the library function would then return a float result in s0, but your code would run off with whatever happened to be left in r0 and be even more wrong.

因此​​,如果您的工具链提供了硬浮点库,你只能链接到他们,如果您编译code作为硬浮动,反之亦然。需要注意的是multilib的神奇手段单一工具链可能通过具有每个库的两个版本,并自动选择合适的人当你链接支持。

Thus if your toolchain provides hard-float libraries, you can only link to them if you compile your code as hard-float, and vice-versa. Note that the magic of multilib means a single toolchain might support both, via having both versions of every library and automatically picking the right one when you link.

这篇关于关于在编制ARM目标应用程序使用的浮点ABI标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆