ELF文件解析 提取source file信息

 必须开启debug模式 -g

readelf --string-dump=.debug_str YOUR_PROGRAM | sed -n '//|.c/{s/.*]  //p}'
readelf --syms YOUR-PROGGRAM |tee /tmp/log

vim /tmp/log
:vim "FILE" %

#You will get all file names, however without path.
readelf --syms YOUR-PROGGRAM | awk '/FILE/{name = $NF; print name}'
readelf -wi YOUR-PROGGRAM | grep -B1 DW_AT_comp_dir |  awk '/DW_AT_name/{name = $NF; getline; print $NF"/"name}'

https://stackoverflow.com/questions/31333337/how-can-i-get-the-source-code-path-file-names-from-an-elf-filecompired-with

原文地址:https://www.cnblogs.com/sinferwu/p/14564971.html