将ARM gcc生成的库从一个软浮点bi转换为硬浮点abi [英] Convert a ARM gcc generated library from one soft float bi to hard float abi

查看:82
本文介绍了将ARM gcc生成的库从一个软浮点bi转换为硬浮点abi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的固件(在使用arm-none-eabi_gcc构建的STM32L4x6上运行)与两个第三方库(我没有这些库的源代码)链接.

I need to link my firmware (running on STM32L4x6, built with arm-none-eabi_gcc) with two third party libraries (I don't have the source code of these libs).

一个库使用硬浮点abi编译,而另一个则根本不使用浮点,并且可能与软浮点abi链接.

One lib is compiled using hard float abi, and the other is not using float at all and linked probably with soft float abi.

我知道两个abis都不兼容,并且我完全理解它们之间的区别,但是,如果一个库根本不使用浮点运算,该怎么办?是什么阻止了使用abi将其与其他代码链接?

I know both abis are not compatible and I fully understand the difference between them, but what if a library does not use float operation at all ? What is preventing to link it with some other code using whatever abi ?

在我搜索过的内容中,无法在这种情况下强制使用链接器,但是有可能将库(.a从gcc)从"一个float abi转换为另一个吗?

From what I've googled it is not possible to force the linker in such a situation, however is it possible to "convert" a library (.a from gcc) from one float abi to another ?

推荐答案

您可以强制链接器通过以下方式接受具有不匹配ABI的对象

You can force the linker to accept objects with mismatched ABIs with

--noinhibit-exec

或(如果通过gcc包装器调用)

or (if it's called through the gcc wrapper)

-Wl,--noinhibit-exec

您会收到一些错误消息,但它仍会生成合理的二进制文件.

You'll get a few error messages, but it still produces a reasonable looking binary.

或者,您可以使用以下方式从目标文件中删除包含ABI信息的属性:

Alternatively, you can remove the attributes containing the ABI information from an object file with

arm-none-eabi-objcopy --remove-section=.ARM.attributes input.o output.o

,链接器随后将很高兴将其与任何内容链接.

and the linker will happily link it with anything afterwards.

如果它不是一个单一的目标文件( .o ),而是一个库( .a ),那么您可能必须使用以下命令从库中提取对象: arm-none-eabi-ar ,然后重新组装.

If it's not a single object file (.o) but a library (.a), then you'll probably have to extract the objects from the library with arm-none-eabi-ar and reassemble it afterwards.

这篇关于将ARM gcc生成的库从一个软浮点bi转换为硬浮点abi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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