问题描述
有没有什么办法可以编译GCC的libstdc ++而不是GNU / Linux的哈希样式SYSV?我有一个工具链(通过crosstool-ng),用于编译我们的公司库,以处理各种Linux系统。
其中一个系统是非常旧的RedHat只有SYSV哈希样式,当我使用工具链编译C语言库/程序时,它很好用,因为生成的二进制文件使用SYSV。
但是,当我与libstdc ++链接时,二进制文件会自动更改为GNU / Linux风格,原因是因为libstdc ++是作为GNU / Linux构建的,因此存在这个问题。
运行二进制在这个系统给我的错误
ELF文件操作系统ABI无效
$为了完整起见,我已经尝试了-Wl, - hash-style = sysv,但没有成功。
b
$ b
提前!
解决方案尝试使用 配置选项。根据GCC配置选项的文档:
lockquote
- enable-gnu-unique-object
- disable-gnu-unique-object
告诉GCC使用gnu_unique_object重新定位C ++模板静态数据成员和内联函数本地静态。默认情况下,对于具有接受GLIBC 2.11或更高版本的汇编程序的工具链启用,否则禁用。
使用gnu_unique_object可能会导致最终可执行文件中的GNU ABI,这在旧版Red Hat中不受支持。 $ b
Is there any way to compile GCC's libstdc++ with hash style SYSV instead of GNU/Linux? I have a toolchain (via crosstool-ng) that I use to compile our company library to work with a very wide range of Linux systems.
One of these system is a very old RedHat that have only SYSV hash style, when I compile a C only library/program with the toolchain, it works great since the generated binary uses SYSV.
But, when I link with libstdc++, the binary automatically changes to GNU/Linux style, the reason is because libstdc++ was built as GNU/Linux, hence the question.
Running the binary in this system gives me the error
ELF file OS ABI invalid
Just for completeness, I have already tried -Wl,--hash-style=sysv, without success.
Also, I have another toolchain for ARM system which have the same version of GCC, GLIBC, etc, but in this toolchain libstdc++ uses SYSV, dunno why.
Thanks in advance!
解决方案Try to rebuild your GCC with --disable-gnu-unique-object configure option. According to documentation on GCC configure options:
Using gnu_unique_object may lead to GNU ABI in your final executable, which is not supported in old Red Hat.
这篇关于使用散列样式SYSV编译libstdc ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!