mnpria
mnpria

Reputation: 15

ldconfig includes libraries from default path also when i have a customized ld-<me>.so.conf

I have cross compiled libraries and a linux loader. I have placed a custom ld-.so.conf under /etc , The conf file has a path that contains all the cross compiled library and the loader.

But when i run ldconfig,

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

All the system libraries and their paths are present in the cache file. I need the cache file generated to contain only my cross compiled libraries.

Strace of ldconfig operation is as below:

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

Can anybody tell me why system libraries are getting added ?

Upvotes: -1

Views: 3788

Answers (1)

William Hay
William Hay

Reputation: 2308

Because that is the defined behavior of 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.

The trusted directory list was probably updated with lib64 dirs sometime after the man page I cut'n'pasted from was written.

You could create a directory structure based on your conf file with symlinks or bind mounts pointing to the real directories and then use -r directory to make ldconfig build based on empty versions of the system directories.

Upvotes: 0

Related Questions