Changing Linkage Table Entries and LD_BIND_NOW
If you are executing a dynamically linked program, calls from the executable into a shared library are made using the Procedure Linkage Table (PLT). Each function in the dynamic library that is called by the main program has an entry in this table. Normally, the dynamic linker fills the PLT entries with code that calls the dynamic linker. This means that the first time that your code calls a function in a dynamic library, the runtime environment calls the dynamic linker. The linker will then modify the entry so that next time this function is called, it will not be involved.
This is not the behavior you want or expect when debugging a program because TotalView will do one of the following:
• Place you within the dynamic linker (which you don't want to see).
• Step over the function.
And, because the entry is altered, everything appears to work fine the next time you step into this function.
You can correct this problem by setting the LD_BIND_NOW environment variable. For example:
setenv LD_BIND_NOW 1
This tells the dynamic linker that it should alter the PLT when the program starts executing rather than doing it when the program calls the function.