I wanted to step into the code of ld.so whenever it will be used in my normal c code.
I am trying to code flow through GDB in the TUI mode where you can see both source code and assembly as you step over the code.
For this I also installed libc-dbg binutils-source package from ubuntu package manager.
GDB can find the debug symbols for the ld.so itself and I can step at the instruction level that is using si but I cant step at the source level as GDB is not able to find the source for ld.so and shows NO Source Available.
How can I make GDB find the source for ld.so so that I can also see which line in the ld.so source is actually being executed.
I am using Ubuntu 12.10 64bit with GCC 4.8.2
If you've libc's source code available, you can add sources to gdb's source path with dir command: Source_Path
Edit: To debug libc related files (in a Ubuntu distro) you would need to:
- Get libc's debug information by installing libc6-dbg packet.
- Get libc's source code by enabling source repositories (by running
software-sourcesand and checking "enable source code repositories") and runningapt-get source libc6 - Add libc's debug information into LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/debugorLD_LIBRARY_PATH=/usr/lib/debug gdb <application> - Add full path to c file to gdb's source path, this is:
dir directory_path_libc_source/stdio-common
Download the Glibc source and path the same with gdb before debugging. Check this ubuntu blog
来源:https://stackoverflow.com/questions/20114565/gdb-step-into-dynamic-linkerld-so-code