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

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

问题描述

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

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 ?

根据我在 google 上搜索的内容,在这种情况下不可能强制链接器,但是是否可以将库(.a from 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.

或者,您可以使用

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天全站免登陆