How does the dynamic loader (libdl) hook in to gdb?

Peter Dufault dufault at hda.com
Thu Jan 16 22:01:06 UTC 2020


I'm trying to hook the SLAC / Til Straumann PowerPC remote debugger stub in to what's loaded by "libdl" via "dlopen()".  *I know* this should be integrated into "libdebugger", and I do keep my eye on that, but I need to keep what is working working and working well.

The "libdl" code has support for GDB both finding out when shared libraries are loaded and resolving the new symbols in "rtl-debugger.c".  It's based on NetBSD and Android.  I don't know how to get this code to kick in.

I hacked the "libdl" "rtl" command to add an option for "rtl list -m", an option that is "rtl list -gm" (Run time loader list a map in a GDB flavor) so that after I load a library such as "loaded_lib" the command will produce something like:

add-symbol-file loaded_lib  -s .text 0x12c0708 -s .rodata 0x12cbb88 -s .data 0x12ce910 -s .bss 0x12cea18

After pasting the output of the "rtl list -gm" command into GDB everything works wonderfully. There are no remote-stub commands that support this, as far as I can tell, and I want to figure out how to do this based on the existing remote-stub interface.  Editorial note:  If I can do it with "add-symbol-file" I should be able to do it from the remote interface, but so it goes.

My question is: How, without modifying GDB, can I add a symbol table after loading something via "dlopen()"?  The interface in "rtl-debugger.c" imply that GDB will poke around and set breakpoints based on a SVR4 dynamic loader in order to locate the information, but I can't figure out how to do it.

Peter
-----------------
Peter Dufault
HD Associates, Inc.      Software and System Engineering

This email is delivered through the public internet using protocols subject to interception and tampering.



More information about the devel mailing list