简体   繁体   English

如何打印linux elf二进制文件中记录的编译目录?

[英]How to print the compilation directory recored in linux elf binary?

The gdb docs say the compilation directory may be recorded in the executable file https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html gdb 文档说编译目录可能记录在可执行文件中https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html

Executable programs sometimes do not record the directories of the source files from which they were compiled, just the names.可执行程序有时不记录编译它们的源文件的目录,只记录名称。 Even when they do, the directories could be moved between the compilation and your debugging session.即使他们这样做,目录也可以在编译和调试会话之间移动。

Assuming the executable file records the compilation directory.假设可执行文件记录了编译目录。 How to print the compilation directory ?如何打印编译目录?

Like so:像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM