gpt4 book ai didi

c - gcc:降低 libc 所需的版本

转载 作者:IT王子 更新时间:2023-10-29 00:20:25 27 4
gpt4 key购买 nike

我正在尝试在一些旧的 32 位 RedHat 发行版上运行新编译的二进制文件。
该二进制文件是在运行 libc v2.12 的 CentOS 32 位 VM 上编译的 C(非++)。

RedHat 提示 libc 版本:

error while loading shared libraries: requires glibc 2.5 or later dynamic linker
由于我的程序相当简单,它很可能没有使用 libc 中的任何新内容。

有没有办法降低 libc 版本要求

最佳答案

未经测试的可能解决方案

What is "error while loading shared libraries: requires glibc 2.5 or later dynamic linker"?

The cause of this error is the dynamic binary (or one of its dependent shared libraries) you want to run only has .gnu.hash section, but the ld.so on the target machine is too old to recognize .gnu.hash; it only recognizes the old-school .hash section.

This usually happens when the dynamic binary in question is built using newer version of GCC. The solution is to recompile the code with either -static compiler command-line option (to create a static binary), or the following option:

-Wl,--hash-style=both

This tells the link editor ld to create both .gnu.hash and .hash sections.

According to ld documentation here, the old-school .hash section is the default, but the compiler can override it. For example, the GCC (which is version 4.1.2) on RHEL (Red Hat Enterprise Linux) Server release 5.5 has this line:

$ gcc -dumpspecs
....
*link:
%{!static:--eh-frame-hdr} %{!m32:-m elf_x86_64} %{m32:-m elf_i386} --hash-style=gnu %{shared:-shared} ....
^^^^^^^^^^^^^^^^
...

For more information, see here.

关于c - gcc:降低 libc 所需的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12075403/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com