C – GDB enters the Dynamic Linker (ld.so) code

GDB enters the Dynamic Linker (ld.so) code… here is a solution to the problem.

GDB enters the Dynamic Linker (ld.so) code

As long as I use it in my normal C code, I want to get into ld.so’s code.
I’m trying to see the pattern of source code and assemblies through the code flow in GDB TUI can see the source code and assemblies across the code.

To do this, I also installed the libc-dbg binutils-source package from the ubuntu package manager.
GDB can find debug symbols for ld.so itself, and I can go to the directive level using si, but I can’t go to the source level because GDB is not able to find the source code for ld.so and display NO Source Available.

How can I get GDB to find the source code for ld.so so I can also see which line of the ld.so source code is actually executing.

I’m using Ubuntu 12.10 64-bit and GCC 4.8.2


If you have the source

code for libc available, you can use dir to add the source to the source path of gdb. Command: Source_Path

EDIT: To debug libc related files (in an Ubuntu distribution), you need:

  1. Obtain debugging information for libc by installing the libc6-dbg package.
  2. Get the source

  3. code for libc by enabling the source repository (by running software-sources and checking “Enable source repository”) and running apt-get source libc6
  4. Add debugging information for libc to LD_LIBRARY_PATH: export LD_LIBRARY_PATH=/usr/lib/debug or LD_LIBRARY_PATH=/usr/lib/debug gdb <application>
  5. Add the full path of the C file to the source path of gdb, i.e.: dir directory_path_libc_source/stdio-common

Related Problems and Solutions