HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 25 (of 101)
Chapter 11 Software Development
October 29, 2013
$ chatr /usr/lib/hpux32/libc.so.1
:
shared library list:
libdl.so.1
:
The ldd(1) tool can be used to list all libraries used by a program, without starting it, in the
order they were loaded if the program was started.
Resolve Symbols
Each time one of the libraries is loaded, all symbols that are still marked as undefined in any
symbol import table (of the executable and all libraries loaded up to now) are checked against the
exported symbols of the current library. And the symbol import table of the loaded library is
checked against all other symbol export tables. References are bound to symbol addresses as
matches are found.
Symbol resolution is nothing but calculating addresses and modifying memory contents. No
system calls are involved in that process. The tusc output provides no additional information
besides showing which libraries are loaded. Symbol resolution in our HelloWorld program shall
be explained with some diagrams and a few symbols.
When loading HelloWorld, it has an unresolved reference to printf, and libc.so.1 is in its
shared library list. The library is loaded, the symbol is found in it and can be resolved:
HelloWorld:
dld.so:
HelloWorld:
exported symbols:
- main
imported symbols:
- printf (unresolved)
library list:
- libc.so.1
- load libc.so.1
- check symbol tables
- resolve matches
exported symbols:
- main
imported symbols:
- printf (resolved)
shared library list:
- libc.so.1
libc.so.1:
libc.so.1: