在模块同级目录下新建.debug目录
[root@localhost]# ls -la
total 28672
drwxr-xr-x 4 root root 4096 Feb 19 17:07 .
drwxr-xr-x 13 root root 4096 Feb 19 17:14 ..
drwxr-xr-x 2 root root 4096 Feb 19 16:21 .debug
查看模块调试信息
[root@localhost]# objdump -s -j .gnu_debuglink libXXX.so
libXXX.so: file format elf64-x86-64
给模块添加调试信息
[root@localhost]# objcopy --add-gnu-debuglink ./.debug/libXXX.so.symbol libXXX.so
查看模块调试信息
[root@localhost]# objdump -s -j .gnu_debuglink libXXX.so
libXXX.so: file format elf64-x86-64
Contents of section .gnu_debuglink:
0000 6c696245 6e744669 72657761 6c6c506c libXXX.so.symbol..
此时用gdb附加进程,会自动加载模块的符号文件
Reading symbols from libXXX.so...Reading symbols from .debug/libXXX.so.symbol...done.
done.