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

Re: dynamic loader behavior question



"Geoffrey L. Brimhall" <brimhall@pobox.com> writes:

> Say I've written a program  that consists of the following parts:
> 
> 1. An executable
> 2. 2 dynamic modules (dynamic1.so and dynamic2.so).
> 3. All of the above binaries are linked with the dynamic version of libc (
> ie libc.so) (*not* the static version of libc (libc.a)).

The main reason for this linkage is to prevent accidental mixture of
libc.so.5 binaries and libc.so.6 binaries.

> My question is this: As each of the binaries in 1-2 are loaded into
> the process, will each load cause libc.so to be loaded, so that in
> effect 3 libc.so's are taking up memory in the process ?

No, they will be linked against the copy of libc.so that is already in
memory.

> Or is their some kindof intellegence where the libc.so consists of a
> 'code' and 'data' part, so that there is only 1 'code' part, but 3
> 'data' parts ? ('data consists of libc.so's data segment).

This is done between processes.  In a single process, there is no need
to duplicate the data segment.

> Finally, is there some {program, shell command, system api} that
> will effectively tell what *.so's are loaded into a process ? Any
> URL's/manuals that go over this some more ?

"ldd" will tell you what shared objects are used at load time.  I
don't know about how to tell whats loaded into a running process.  You
could probably do it by digging through /proc, if you knew the inode
numbers of the libraries, and I believe that gdb has some mechanism of
determining this (you could probably attach gdb to the process and ask
it what shared objects are loaded.


Steve
dunham@cps.msu.edu


--  
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: