1

I want to know, where .so file information got stored in linux? I am looking for libruby.so.2.6.

When I searched in internet, ld.so first starts the search with LD_LIBRARY_PATH and then it will look for ld.so.conf file and cache files and then the default paths like /lib and /usr/local/lib.

In my case ruby got installed in /opt/puppetlabs/puppet/root/bin location and when I executed ldd /opt/puppetlabs/puppet/root/bin, got the location of the libruby.so as /opt/puppetlabs/puppet/lib/libruby.so.2.6.

Now I am able to get the location of the shared object, but I would like to know from where it got the details? I have checked the ld_library_path and ld.so.conf file, I could find that entry. Could someone please help me to get this detail?

Smar
  • 131
  • 8

1 Answers1

0

The man page for ldd says:

   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. 

The man page for ld gives the explanation of the rules:

   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.
Bert
  • 2,733
  • 11
  • 12