问题
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).
One lib is compiled using hard float abi, and the other is not using float at all and linked probably with soft float 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 ?
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 ?
回答1:
You can force the linker to accept objects with mismatched ABIs with
--noinhibit-exec
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.
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.
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.
回答2:
The only way I can think off it is another C wrapper where you define functions which will be linked against the soft and hard floats. It is the workaround of course but you need to show the compiler how to pass the parameters to the functions.
来源:https://stackoverflow.com/questions/51398676/convert-a-arm-gcc-generated-library-from-one-soft-float-bi-to-hard-float-abi