This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How does dynamic loading of libnss_dns.so et al work?


  Hello,

On Wed, May 13, 2009 at 06:14:52PM +0200, Arvid Brodin wrote:
> I need to find all dynamic libraries needed by a set of cross-built binaries. To do this, I use 'objdump -x <binary> | grep NEEDED', which gives me a list of the dynamic libraries needed by that particular binary. I then iterate the objdump on the list of libraries, until I cannot find any more dependencies.
> 
> However, this does not work for the Name Service Switch libraries; libnss_dns.so is not listed as a NEEDED library in the objdump, but name lookup still fails with e.g.: "ping: bad address 'google.com.'" if this library and its dependencies (libresolv.so) are missing on the target system. (Using busybox ping, which calls getaddrinfo().)
> 
> In fact, grepping on nss_dns gives no hits at all on any on the involved binaries or libs (busybox, libcrypt, libm, libc, ld-linux). Which makes me wonder: how can the executable know to load libnss_dns? What's the mechanism used to load this file (and libnss_files.so, etc.)?

  the executable calls libc, which will call the appropriate NSS module
using dlopen() - applications can load additional .so libraries on the
fly, without direct indication in any ELF section. The loading of NSS
modules is governed by /etc/nsswitch.conf. The pthreads library and
backtrace() can also dynamically load libgcc_s.so, while the iconv()
function will dynamically load modules for various charsets (usually in
/usr/lib/gconv).

-- 
				Petr "Pasky" Baudis
The lyf so short, the craft so long to lerne. -- Chaucer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]