gpt4 book ai didi

c++ - glibc 版本早于 gcc 版本和 -Wl,-rpath 不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:19:32 24 4
gpt4 key购买 nike

我正在为 armhf 进行交叉编译,编译过程很顺利,但是 GLIBC 版本很旧,./libc.so.6 显示它是由 gcc 4.6.3 编译的,不幸的是我在 apt-get 上找不到这个旧版本。所以我尝试使用 follow LDFLAG 选项重新定位 lib 路径。

-Wl,-rpath,/boxer/lib -Wl,--dynamic-linker,/boxer/lib/ld-linux-armhf.so.3

并部署了相应的库到/boxer/lib,但问题没有解决,./ld-linux-armhf.so.3 --list显示ld链接正确地方,但是,正如你在下面看到的,其余的不是。

root@cubieboard2:/lib/arm-linux-gnueabihf# ./ld-linux-armhf.so.3 --list /boxer/frida-server
/boxer/frida-server: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by /boxer/frida-server)
libresolv.so.2 => /lib/arm-linux-gnueabihf/libresolv.so.2 (0xb6f7a000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6f6e000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6f53000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e6f000)
/boxer/lib/ld-linux-armhf.so.3 => ./ld-linux-armhf.so.3 (0xb6f9e000)

有什么建议吗?谢谢。

更新:

这是LD_TRACE_LOADED_OBJECTS=1选项的结果,好像和上面一样

root@cubieboard2:/boxer# LD_TRACE_LOADED_OBJECTS=1 /boxer/frida-server
/boxer/frida-server: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by /boxer/frida-server)
libresolv.so.2 => /lib/arm-linux-gnueabihf/libresolv.so.2 (0xb6f10000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6f05000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6eea000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e06000)
/boxer/lib/ld-linux-armhf.so.3 (0xb6f28000)
root@cubieboard2:/boxer#

ld-linux 有正确的去处,但其他的仍然在老路...

这是我之前使用 QT 编译的另一个程序,带有 rpath LDFLAG:

QMAKE_LFLAGS +=-Wl,-rpath,/boxer/lib -Wl,--dynamic-linker,/boxer/lib/ld-linux.so.3

是的,我关注了your answer它工作正常(谢谢,帮助很大 :-)),LD_TRACE_LOADED_OBJECTS=1 结果:

# LD_TRACE_LOADED_OBJECTS=1 /boxer/Boxer
libdl.so.2 => /boxer/lib/libdl.so.2 (0xb6efb000)
libQt5Widgets.so.5 => /boxer/lib/libQt5Widgets.so.5 (0xb69b9000)
libQt5Gui.so.5 => /boxer/lib/libQt5Gui.so.5 (0xb655f000)
libQt5Network.so.5 => /boxer/lib/libQt5Network.so.5 (0xb646f000)
libQt5Core.so.5 => /boxer/lib/libQt5Core.so.5 (0xb5f50000)
libpthread.so.0 => /boxer/lib/libpthread.so.0 (0xb5f27000)
libstdc++.so.6 => /boxer/lib/libstdc++.so.6 (0xb5ddc000)
libm.so.6 => /boxer/lib/libm.so.6 (0xb5d2a000)
libgcc_s.so.1 => /boxer/lib/libgcc_s.so.1 (0xb5cfa000)
libc.so.6 => /boxer/lib/libc.so.6 (0xb5bb5000)
/boxer/lib/ld-linux.so.3 (0xb6f0e000)
librt.so.1 => /boxer/lib/librt.so.1 (0xb5b9e000)

我们可以看到一切顺利,包括 libc,有什么不同?

最佳答案

GLIBC version is old ,./libc.so.6 shows it was compiled by gcc 4.6.3, unfortunately i can't find this old version on apt-get.

请注意,GLIBC 的版本很少与编译它的 GCC 版本有关。较新版本的 GLIBC 确实需要较新版本的 GCC 来构建它们,但这种关系远非一对一。

deployed the corresponding library to /boxer/lib,but the problem not solve,and ./ld-linux-armhf.so.3 --list shows that the ld was linked to correct place,but,as u can see below, the rest not.

您需要使用 --prefix=/boxer 构建 GLIBC,以便 ld-linux 在备用位置查找。另见 this answer .

更新:

我误解了你的问题。这个命令:

./ld-linux-armhf.so.3 --list /boxer/frida-server

不会告诉您您想知道的内容(哪些库将在运行时加载),因为它不会关注编译到应用程序中的RPATH (它只使用编译到 ld-linux 本身的路径)。

相反,您想要:

LD_TRACE_LOADED_OBJECTS=1 /boxer/frida-server

它显示了实际上将加载哪些库。

关于c++ - glibc 版本早于 gcc 版本和 -Wl,-rpath 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45512958/

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