how can i get the source code path && file names from an ELF file(compired with -g)?

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

readelf holds the key, but you don't want to dump strings willy-nilly. Use the -wi option to properly format the info.
For example, create a shell script thus:

readelf -wi $1 | grep -B1 DW_AT_comp_dir | \
    awk '/DW_AT_name/{name = $NF; getline; print $NF"/"name}'

which further summarizes the output of readelf -wi.

posted @ 2017-12-16 20:28  阿C  阅读(377)  评论(0)    收藏  举报