为什么不尊重'-rpath-link'选项?

时间:2009-12-01 09:27:34

标签: linux linker elf ld

我使用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路径。

1 个答案:

答案 0 :(得分:3)

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

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