dbx and the Dynamic Linker
This chapter is organized into the following sections:
The dynamic linker, also known as rtld, RunTime ld, or ld.so, arranges to bring shared objects (load objects) into an executing application. There are two primary areas where rtld is active:
dbx traverses the link map to see:
stop in printf
requires special consideration by dbx. Whenever you load a new program, dbx automatically executes the program up to the point where rtld has completed construction of the link map. dbx then reads the link map and stores the base addresses. After that, the process is killed and you see messages and the prompt. These dbx tasks are completed silently.
Startup Sequence and .init Sections
A .init section is a piece of code belonging to a shared object that is executed when the shared object is loaded. For example, the .init section is used by the C++ runtime system to call all static initializers in a .so.
dlopen() and dlclose()
dbx automatically detects that a dlopen or a dlclose has occurred and loads the symbol table of the loaded object. You can put breakpoints in and debug the loaded object like any part of your program.
fix and continue
Using fix and continue with shared objects requires a change in how they are opened in order for fix and continue to work correctly. Use mode RTLD_NOW|RTLD_GLOBAL or RTLD_LAZY|RTLD_GLOBAL.
Procedure Linkage Tables (PLT)
PLTs are structures used by the rtld to facilitate calls across shared object boundaries. For instance, the call to printf goes via this indirect table. The details of how this is done can be found in the generic and processor specific SVR4 ABI reference manuals.
Setting a Breakpoint in a Dynamically Linked Library
dbx provides full debugging support for code that makes use of the programmatic interface to the run-time linker; that is, code that calls dlopen(), dlclose() and their associated functions. The run-time linker binds and unbinds shared libraries during program execution. Debugging support for dlopen()/dlclose() allows you to step into a function or set a breakpoint in functions in a dynamically shared library just as you can in a library linked when the program is started.