c - Find executable that a core dump was generated against -
is there way embed version info such git commit hash in elf executable such can retrieved core dumps generated it?
see this question git hash.
then, change build procedure (e.g. makefile
) include it. instance, generate 1 line c file with
git log --pretty=format:'const char program_git_hash[] = "%h";' \ -n 1 > _prog_hash.c
then link program _prog_hash.c
, remove file after linking. add timestamping information e.g.
date +'const char program_timestamp="%c";%n' >> _prog_hash.c
then use gdb
or strings
on binary executable find it.
you may want declare extern const char program_git_hash[];
in header file, , perhaps display (e.g. when passing --version
option program)
Comments
Post a Comment