gpt4 book ai didi

linux - 当我有自定义的 ld-.so.conf 时,ldconfig 也包含默认路径中的库

转载 作者:太空宇宙 更新时间:2023-11-04 04:09:57 26 4
gpt4 key购买 nike

我有交叉编译的库和一个 Linux 加载器。我在/etc 下放置了一个自定义的 ld-.so.conf ,该conf文件的路径包含所有交叉编译库和加载器。

但是当我运行 ldconfig 时,

ldconfig -C/etc/ld-.so.cache -f/etc/ld-.so.conf

所有系统库及其路径都存在于缓存文件中。我需要生成的缓存文件仅包含我的交叉编译库。

ldconfig操作的strace如下:

strace /opt/me/ldconfig -C /etc/ld-me.so.cache -f /etc/ld-me.so.conf execve("/opt/me/ldconfig", ["/opt/me/ldc"..., "-C", "/etc/ld-me.so.cache", "-f", "/etc/ld-me.so.conf"], [/* 38 vars */]) = 0

uname({sys="Linux", node="ip-172-31-32-236", ...}) = 0 brk(0)
= 0x10c1000 brk(0x10c2180) = 0x10c2180 arch_prctl(ARCH_SET_FS, 0x10c1860) = 0 brk(0x10e3180)
= 0x10e3180 brk(0x10e4000) = 0x10e4000 open("/usr/lib/locale/locale-archive", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=99154480, ...}) = 0 mmap(NULL, 99154480, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f46155a4000 close(3)
= 0 open("/etc/ld-me.so.conf", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0640, st_size=25, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f46155a3000 read(3, "/opt/me/lib\n", 4096) = 25 stat("/opt/me/lib", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0 read(3, "", 4096)
= 0 close(3) = 0 munmap(0x7f46155a3000, 4096) = 0 stat("/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 stat("/lib64", {st_mode=S_IFDIR|0555, st_size=12288, ...}) = 0 stat("/usr/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 stat("/usr/lib64", {st_mode=S_IFDIR|0555, st_size=12288, ...}) = 0 open("/opt/me/lib", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3

谁能告诉我为什么要添加系统库?

最佳答案

因为这是 ldconfig 定义的行为:

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated.

在编写我剪切粘贴的手册页后,可信目录列表可能已使用 lib64 目录进行了更新。

您可以根据您的conf文件创建一个目录结构,并使用符号链接(symbolic link)或绑定(bind)挂载指向真实目录,然后使用-r 目录使 ldconfig 基于系统目录的空版本构建。

关于linux - 当我有自定义的 ld-<me>.so.conf 时,ldconfig 也包含默认路径中的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19657438/

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