为什么 ld 不尊重“-rpath-link”?选项?

发布于 2024-08-12 19:05:27 字数 1057 浏览 4 评论 0原文

我使用 strace 检测到这一点:

8480  execve("/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld", 
[   "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld", 
    ...
    "-L/home/bjack/lib", 
    ...
    "-rpath-link", "/root/src/firmware/Bj-bg/ab-BJ-gameprom-modules/src/dispatcher/logic", 
    ...
    "-lgame_std", "-lygor", "-ldl", 
    "--rpath", "/home/bjack/lib", 
    "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", 
    "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtend.o", 
    "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crtn.o"
], [/* 26 vars */]) = 0

8480  open("/home/bjack/lib/libgame_std.so", O_RDONLY) = 12
8480  open("/home/bjack/lib/libygor.so", O_RDONLY) = -1 ENOENT (No such file or directory)
8480  open("/home/bjack/lib/libygor.a", O_RDONLY) = -1 ENOENT (No such file or directory)

我很困惑;根据手册ld首先必须尝试在-rpath-link路径中查找。

I detect this using strace:

8480  execve("/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld", 
[   "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld", 
    ...
    "-L/home/bjack/lib", 
    ...
    "-rpath-link", "/root/src/firmware/Bj-bg/ab-BJ-gameprom-modules/src/dispatcher/logic", 
    ...
    "-lgame_std", "-lygor", "-ldl", 
    "--rpath", "/home/bjack/lib", 
    "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", 
    "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtend.o", 
    "/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crtn.o"
], [/* 26 vars */]) = 0

8480  open("/home/bjack/lib/libgame_std.so", O_RDONLY) = 12
8480  open("/home/bjack/lib/libygor.so", O_RDONLY) = -1 ENOENT (No such file or directory)
8480  open("/home/bjack/lib/libygor.a", O_RDONLY) = -1 ENOENT (No such file or directory)

I'm confused; according to the manual ld at first must try to find at -rpath-link path.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热情消退 2024-08-19 19:05:27

-rpath-link 仅记录(在 ld(1) 手册页中)以影响依赖于其他共享库的共享库。由于您正在链接可执行文件,因此它要么被忽略,要么被视为另一个 -rpath。或者这可能意味着 -rpath-link 路径仅用于递归依赖项,但您在链接可执行文件时确实设置了它。

无论如何,我认为它没有被使用,因为你没有一个库依赖于另一个库。

-rpath-link is only documented (in the ld(1) man page) to affect shared libs that depend on other shared libs. Since you're linking an executable, either it's ignored or it's treated like just another -rpath. Or maybe it means that the -rpath-link path is only used for recursive dependencies, but you do set it when linking the executable.

Anyway, I think it's not being used because you don't have one library depending on another.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文