next up previous
Next: Programming in Assembly Up: ELF under Linux Previous: Loading additional shared

Dynamic loading under Linux

There is a function in the dynamic linker interface library, _dlinfo. It lists all modules currently mapped in by the executable and each shared library opened via dlopen. The output may look like:

List of loaded modules
        00000000 50006163 50006200 Exe 1 
        50007000 5000620c 50006200 Lib 1 /lib/elf/libdl.so.1
        5000a000 500062c8 50006200 Lib 2 /lib/elf/libc.so.4
        50000000 50006000 00000000 Int 1 /lib/elf/ld-linux.so.1
        500aa000 08006f00 08005ff0 Mod 1 ./libfoo.so

Modules for application (50006200):
        50006163 
        5000620c /lib/elf/libdl.so.1
        500062c8 /lib/elf/libc.so.4
        50006000 /lib/elf/ld-linux.so.1
Modules for handle 8005ff0
        08006f00 ./libfoo.so
        500062c8 /lib/elf/libc.so.4
        50006163 
        5000620c /lib/elf/libdl.so.1
        500062c8 /lib/elf/libc.so.4
        50006000 /lib/elf/ld-linux.so.1

It can be used to examine the dynamic linking and dynamic loading.

gcc configured for Linux running ELF passes -export-dynamic to the linker if the -rdynamic option is used. It is highly recommended for any executables which use dynamic loading. That is the reason why LDFLAGS=-rdynamic was in Makefile in our example. For the time being, this option only works under Linux. But -Wl,-export-dynamic can be used to pass -export-dynamic to be the GNU linker on other platforms.

You can find the detailed descriptions about gcc and GNU link editor in [3] and [4].



J.H.M.Dassen
Tue Aug 1 14:18:10 MDT 1995