$ cc
$ ld
ldd(1) shows the order in which the shared libraries are loaded:
$ ldd a.out |
| |
libA.so | => | ./libA.so |
libB.so | => | ./libB.so |
libc.so.1 => | /usr/lib/hpux32/libc.so.1 | |
libdl.so.1 => | /usr/lib/hpux32/libdl.so.1 |
The symbol resolution order for the user libraries is:
a.out-
If the LD_PRELOAD environment variable is set to "./libC.so", the symbol resolution order is:
$ export LD_PRELOAD=./libC.so
$ ldd a.out |
|
./libC.so => | ./libC.so |
libA.so => | ./libA.so |
libB.so => | ./libB.so |
libc.so.1 => | /usr/lib/hpux32/libc.so.1 |
libdl.so.1 => | /usr/lib/hpux32/libdl.so.1 |
a.out
LD_PRELOAD Example
The PA64 linker toolset searches dependent libraries in a
a.out
/\
libA.sl libB.sl
/\
libC.sl libD.sl
That is, a.out is built with commands like these:
$ cc +DA2.0W
$ ld
In
$ ldd a.out |
|
libA.sl => | ./libA.sl |
libB.sl => | ./libB.sl |
libc.2 => | /usr/lib/pa20_64/libc.2 |
libC.sl => | ./libC.sl |
libD.sl => | ./libD.sl |
libdl.1 => | /usr/lib/pa20_64/libdl.1 |
Therefore, with LD_PRELOAD unset, the symbol resolution order for the user libraries in
a.out-
Case (i): LD_PRELOAD="./libB.sl" In
104 Creating and Using Libraries