GDB step in dynamic linker code (ld.so)

I wanted to enter the ld.so code whenever it would be used in my regular c code. I am trying to execute code through GDB in TUI mode, where you can see both the source code and the assembly when you go through the code.

For this, I also installed the libc-dbg binutils-source package from the ubuntu package manager. GDB can find debugging symbols for ld.so itself, and I can go to the instruction level that si uses, but I cannot go to the source level, because GDB cannot find the source for ld.so and shows NO Source Available .

How can I get GDB to find the source for ld.so so that I can also see which line in the ld.so source ld.so actually running.

I am using Ubuntu 12.10 64bit with GCC 4.8.2

+1
c linux linker glibc gdb
source share
2 answers

If you have the libc source code, you can add sources to the gdb source path with the dir command: Source_Path

Edit: To debug libc-related files (in the Ubuntu distribution), you need to:

  • Get libc debugging information by installing the libc6-dbg package.
  • Get the libc source code by enabling the source repositories (by running software-sources and turning on "enable source code repositories") and running apt-get source libc6
  • Add libc debugging information to LD_LIBRARY_PATH: export LD_LIBRARY_PATH=/usr/lib/debug or LD_LIBRARY_PATH=/usr/lib/debug gdb <application>
  • Add the full path to the c file to the path to the gdb source, this: dir directory_path_libc_source/stdio-common
+3
source share

Download the Glibc source and specify the same with gdb before debugging. Check out the ubuntu blog

0
source share

All Articles