Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

elf

I want to get the source code path && source names just through the ELF file, the .debug_str section contains what i need, but how can i filter them out?

like image 890
codercheng Avatar asked Jul 10 '15 05:07

codercheng


2 Answers

$ readelf --string-dump=.debug_str YOUR_PROGRAM

works fine.

However, make sure your_program is not stripped by using command

file YOUR_PROGRAM
like image 160
keniee van Avatar answered Sep 28 '22 04:09

keniee van


I suggest to use this command and tools like sed or grep.

$ readelf --string-dump=.debug_str YOUR_PROGRAM

this show path and source file name:

$ readelf --string-dump=.debug_str YOUR_PROGRAM | sed -n '/\/\|\.c/{s/.*\]  //p}'
like image 40
Gnukos Avatar answered Sep 28 '22 04:09

Gnukos