我有交叉编译的库和一个 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 关闭(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 读取(3, "/opt/me/lib\n ", 4096) = 25 stat("/opt/me/lib", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0 读取(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 打开("/opt/me/lib", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
谁能告诉我为什么要添加系统库?