If the C_FLAGS
during compilation contain the -g
parameter, then all the paths of individual source files are included in the .debug_info
section in the resulting binary executable.
The following command will dump to the console, a complete list of all the paths to various .c
source files that are present in the binary built with debug-info.
$ readelf --debug-dump=info <binary-executable> | grep "\.c" | awk '{print $8}'
To search for the path of a particular source-file within the debug-info of the binary, one can modify the grep "\.c"
to grep "<filename>"
as appropriate.
For more details, checkout this excellent article on debug-info in binaries.