我想知道,.so
文件信息在 Linux 中存储在哪里?我正在寻找libruby.so.2.6
。
当我在互联网上搜索时,ld.so
首先用开始搜索LD_LIBRARY_PATH
,然后它会查找ld.so.conf
文件和缓存文件,然后是默认路径,如/lib
和/usr/local/lib
。
在我的例子中,ruby 安装在了/opt/puppetlabs/puppet/root/bin
位置上,当我执行时,获得了asldd /opt/puppetlabs/puppet/root/bin
的位置。libruby.so
/opt/puppetlabs/puppet/lib/libruby.so.2.6
现在我能够获取共享对象的位置,但我想知道它从哪里获得详细信息?我检查了文件ld_library_path
,ld.so.conf
可以找到该条目。有人能帮我获取这个详细信息吗?
答案1
的手册页ldd
显示:
In the usual case, ldd invokes the standard dynamic linker (see
ld.so(8)) with the LD_TRACE_LOADED_OBJECTS environment variable set
to 1. This causes the dynamic linker to inspect the program's
dynamic dependencies, and find (according to the rules described in
ld.so(8)) and load the objects that satisfy those dependencies.
的手册页ld
给出了解释规则:
When resolving shared object dependencies, the dynamic linker first
inspects each dependency string to see if it contains a slash (this
can occur if a shared object pathname containing slashes was
specified at link time). If a slash is found, then the dependency
string is interpreted as a (relative or absolute) pathname, and the
shared object is loaded using that pathname.
If a shared object dependency does not contain a slash, then it is
searched for in the following order:
o Using the directories specified in the DT_RPATH dynamic section
attribute of the binary if present and DT_RUNPATH attribute does
not exist. Use of DT_RPATH is deprecated.
o Using the environment variable LD_LIBRARY_PATH, unless the
executable is being run in secure-execution mode (see below), in
which case this variable is ignored.
o Using the directories specified in the DT_RUNPATH dynamic section
attribute of the binary if present. Such directories are searched
only to find those objects required by DT_NEEDED (direct
dependencies) entries and do not apply to those objects' children,
which must themselves have their own DT_RUNPATH entries. This is
unlike DT_RPATH, which is applied to searches for all children in
the dependency tree.
o From the cache file /etc/ld.so.cache, which contains a compiled
list of candidate shared objects previously found in the augmented
library path. If, however, the binary was linked with the -z
nodeflib linker option, shared objects in the default paths are
skipped. Shared objects installed in hardware capability
directories (see below) are preferred to other shared objects.
o In the default path /lib, and then /usr/lib. (On some 64-bit
architectures, the default paths for 64-bit shared objects are
/lib64, and then /usr/lib64.) If the binary was linked with the
-z nodeflib linker option, this step is skipped.