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
.