2

gdb 文档说编译目录可能记录在可执行文件中https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html

可执行程序有时不记录编译它们的源文件的目录,只记录名称。即使他们这样做了,目录也可以在编译和调试会话之间移动。

假设可执行文件记录编译目录。如何打印编译目录?

4

1 回答 1

4

像这样:

cd /tmp
gcc -g t.c
readelf -Wwi a.out | grep DW_AT_comp_dir

    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x2ab): /tmp
于 2020-04-01T22:38:07.093 回答