How to know the name and/or path of the debug symbol file which is linked to a binary executable?

老子叫甜甜 提交于 2019-12-12 10:43:44

问题


How to know the name and/or path of the debug symbol file which is linked to a binary executable?

Suppose you did like this:

objcopy --only-keep-debug foo foo.dbg
objcopy --strip-debug foo
objcopy --add-gnu-debuglink=foo.dbg foo

Now foo.dbg has debug symbols, foo only has the link to foo.dbg that gdb can use. Since gdb can know the symbol file from foo, how can we know same without actually running gdb?

I have observed that even if I rename the executable from foo to xyz still gdb loads symbols from foo.dbg so it is not like binaryname.extension, and extension is optional anyway.


回答1:


how can we know same without actually running gdb?

Either of these commands will tell you:

readelf -x.gnu_debuglink foo
objdump -sj.gnu_debuglink foo

The objcopy --add-gnu-debuglink simply adds .gnu_debuglink section containing the given path, and a checksum of the debug file.

More info here.



来源:https://stackoverflow.com/questions/42750115/how-to-know-the-name-and-or-path-of-the-debug-symbol-file-which-is-linked-to-a-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!