As far as I understand your question, you need to add a version line to each object file without touching the sources. This can be done as follows.
Create a header file, for example include/version.h :
#ifndef VERSION_H #define VERSION_H static const char _ver[] __attribute__((used)) = "VERSION/foo.c/1.01/09.04.15"; #endif
Then in your Makefile (or whatever your build system is) add the following gcc flag:
CPPFLAGS += -include include/version.h
Of course, it should be passed to gcc , for example. eg:
%.o: %.c $(CC) $(CFLAGS) $(CPPFLAGS) -o $(*).o -c $(*).c
Now you can observe the _ver line compiled for each object file:
$ objdump -DS src/main.o | grep _ver
What will be shown to you something like this:
Disassembly of section .rodata._ver: 00000000 <_ver>:
Sam protsenko
source share