프로그래밍/리눅스 프로그래밍

[GDB] shared library debug symbol loading

jinkwon.kim 2023. 11. 22. 14:42
728x90
반응형

https://stackoverflow.com/questions/30281766/need-to-load-debugging-symbols-for-shared-library-in-gdb/66562021#66562021

 

Need to load debugging symbols for shared library in GDB

I am using GDB to debug a program that uses libpthread. There is an error happening in pthread_create and need to step into that function. Unfortunately when I am debugging my program, it does not...

stackoverflow.com

요약

gdb에서 load한 shared libary의 시작 주로를 확인

(gdb) add-symbol-file {symbol 정보가있는 library 경로} {info shared library에 나오는 library의 FROM 값}

Loading debug symbols for a shared library

If the shared library is stripped, and the debug symbols are provided as a separate file, you need to load them after the shared library was loaded by the linker. The symbols should be loaded on the memory address where the shared library is loaded.

Following is an example of loading the symbols:

  1. Find the memory location where the shared library that you want to debug was loaded (in this example the library is libtest.so.1so, the library is loaded starting from memory address 0x0000fffff7f9f890
  2. (gdb) info sharedlibrary
    From To Syms Read Shared Object Library
    0x0000fffff7fcd0c0 0x0000fffff7fe5468 Yes (*) /lib/ld-linux-aarch64.so.1
    0x0000fffff7f9f890 0x0000fffff7fb65c0 Yes (*) /usr/local/lib/libtest.so.1
    0x0000fffff7e4bbc0 0x0000fffff7f3b190 Yes /lib/aarch64-linux-gnu/libc.so.6
    0x0000fffff7dfea50 0x0000fffff7e0ddec Yes /lib/aarch64-linux-gnu/libpthread.so.0
  3. Load the symbol file with the address from the share library
  4. (gdb) add-symbol-file ./libsrc/libtest.dbg 0x0000fffff7f9f890
    add symbol table from file "./libsrc/libtest.dbg" at .text_addr = 0xfffff7f9f890 (y or n) y
    Reading symbols from ./libsrc/libtest.dbg...
728x90
반응형