How to get the information of the dynamic linkink library in UNIX?

K

K.S.Liang

Hi all,

1> If there are more than one dynamic linking libraries in the file
system, how do I know which one is loaded into system? Any C library
or system call can tell me which *.so or *.sl is active? Can the
setting of LD_LIBRARY_PATH guanrantee that the correct one is
executed?

2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
will be used by the subsequent appication. Does UNIX have the same
mechanism?

3> Or in UNIX the application always load the dynamic linking library
according to the paths specified by LD_LIBRARY_PATH.

4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???


Thanks for your help.


Regards,

K.S.Liang
 
A

Artie Gold

K.S.Liang said:
Hi all,

1> If there are more than one dynamic linking libraries in the file
system, how do I know which one is loaded into system? Any C library
or system call can tell me which *.so or *.sl is active? Can the
setting of LD_LIBRARY_PATH guanrantee that the correct one is
executed?

2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
will be used by the subsequent appication. Does UNIX have the same
mechanism?

3> Or in UNIX the application always load the dynamic linking library
according to the paths specified by LD_LIBRARY_PATH.

4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???
And your C question is?
[hint: on news:comp.unix.programmer this might be appropriate]

--ag
 
D

Derk Gwen

(e-mail address removed) (K.S.Liang) wrote:
# Hi all,
#
# 1> If there are more than one dynamic linking libraries in the file
# system, how do I know which one is loaded into system? Any C library
# or system call can tell me which *.so or *.sl is active? Can the
# setting of LD_LIBRARY_PATH guanrantee that the correct one is
# executed?

Different unices have different mechanisms and different guarentees. There's no
universal unix answer. Darwin, for example, allows one path to the library to
be compiled into the code, and then searches a predetermined list of
Library directories.

# 2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL
# will be used by the subsequent appication. Does UNIX have the same
# mechanism?

Sometimes different members of a library may be crosslinked to prefer other members
of the same library rather than a previously loaded definition of a symbol. Depends
on the unix and how the libraries are constructed.

# 3> Or in UNIX the application always load the dynamic linking library
# according to the paths specified by LD_LIBRARY_PATH.

Not all unices even look at any environmental variable.

# 4> Can the applications belonged to different user share the same
# dynamic linking library? If not, how could it be called shared
# library???

A library or executable file consists of read only pages and pages that can be
modified by the program. Usual virtual memory semantics require changes to
pages to be isolated from other processes: these pages cannot be shared by
different processes. Read only pages will always be the same in every process
that loads them: they can be shared. The shared means more than one process can
have the same page in their different address spaces. Read only pages of executables
can also be shared.

A shared library is either loaded at the same vm address everytime (which can lead
to conflicts if two libraries load at the address), or the library code is compiled
so that its code pages can be loaded at any addresses without modifying the code
(using PC-relative branches or jumps through special linkage pages).

Static library code is copied into the executable file. The code can contain
relocatable addresses that are modified as it is loaded into the executable, modifying
the code pages when copied into the executable, but not modified while the
executable itself is running. As far as I know static libraries are no longer
linked dynamically in a running program: shared libraries can do this better
and cheaper. The static library file itself need not be present when the executable
is running: all relevant parts of library have already been incorporated into the
executable.

Different applications belonging to different users can share the same dynamic
library pages. Most unix programs use the C library; the kernel can arrange it so
there is only single copy of the library code in vm. This can greatly reduce the
number of pages required to run programs. Different applications of the same user
can share library pages. The same application in different processes (different
or same users) can share the executable pages.
 
K

Kevin Easton

Derk Gwen said:
(e-mail address removed) (K.S.Liang) wrote: [...]
4> Can the applications belonged to different user share the same
dynamic linking library? If not, how could it be called shared
library???

A library or executable file consists of read only pages and pages that can be
modified by the program. Usual virtual memory semantics require changes to
pages to be isolated from other processes: these pages cannot be shared by
different processes. Read only pages will always be the same in every process
that loads them: they can be shared.

Even writeable pages can be shared between processes, if the OS supports
Copy-On-Write semantics for pages.

- Kevin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top