[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: making a static binary out a dynamic




On Wed, 3 Jan 2001, Mevorach, Assaf wrote:

> hey even for the sake of the argument you cant pretend you dont know that
> libc DOESNT use dynamic load library (dlopen).

why do you think that? libc contains code that uses /etc/nsswitch.conf to
check where to get certain types of info from (files, nis, nisplus...) and
it then dynamically loads a library that has functions to access those
files. how you could see that? 'ldd' a file on your system, such as
'/usr/bin/top'. here is the output on this redhat 6.2 system:

[choo@simey ~]$ ldd /usr/bin/top
        libproc.so.2.0.6 => /lib/libproc.so.2.0.6 (0x4001a000)
        libncurses.so.4 => /usr/lib/libncurses.so.4 (0x40026000)
        libc.so.6 => /lib/libc.so.6 (0x40068000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)


then run 'top', check its PID, and run '/usr/sbin/lsof -p <PID>'.
here is the output on this machine:

[choo@simey ~]$ /usr/sbin/lsof -p 863
COMMAND PID USER   FD   TYPE DEVICE    SIZE  NODE NAME
top     863 choo  cwd    DIR   3,67    6144 51150 /prog/choo
top     863 choo  rtd    DIR    3,2    1024     2 /
top     863 choo  txt    REG    3,3   34896 34672 /usr/bin/top
top     863 choo  mem    REG    3,2  340663 13952 /lib/ld-2.1.3.so
top     863 choo  mem    REG    3,2   44108 14056 /lib/libproc.so.2.0.6
top     863 choo  mem    REG    3,3  262884 12216
/usr/lib/libncurses.so.4.0
top     863 choo  mem    REG    3,2 4101324 13959 /lib/libc-2.1.3.so
top     863 choo  mem    REG    3,2  246652 13990
/lib/libnss_files-2.1.3.so
top     863 choo    0u   CHR    4,4          7479 /dev/tty4
top     863 choo    1u   CHR    4,4          7479 /dev/tty4
top     863 choo    2u   CHR    4,4          7479 /dev/tty4
top     863 choo    3r   REG    0,1       0     3 /proc/uptime
top     863 choo    4r   REG    0,1       0    17 /proc/stat
top     863 choo    5r   REG    0,1       0     2 /proc/loadavg
top     863 choo    6r   REG    0,1       0     4 /proc/meminfo


as you can see, libnss_files-2.1.3 was magically opened by 'top', and this
is not something that 'top' does on its own - its part of libc's services.

> BTW,where/Why did you gather all this knowledge about Linux/Unix
> executable and linkable format ?

why? because i needed some of it, and was curious about the rest. how?
reading, playing and experimenting with processes. some of it is due to
work. some of it - from people such as you.

--
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il