> On Thu, Dec 07, 2000 at 06:41:11PM +0100, Donal Mcnamee (LMI) mentioned:
> > Is there any utility that can embed comments (e.g. the version of the .c
> > files used to make the binary) into the binary itself.
>> gcc -g file.c -o file
>> will make a file with debugging info. It'll include the complete source
No it won't. The debugging info doesn't contain the source code.
It contains the filenames of the source files and tables that map
code addresses to line numbers so that a debugger can locate the
relevant source lines.
> > And then is there such program that can be run against this binary to
> > return this information?
>> Well, gdb will let you run "list" over the binary, showing line numbers &
> the source.
gdb tries to locate the source file and opens it directly.
What you want to do is make static string variables at the top
of each .c file:
static const char id = "file.c 22.214.171.124";
(Use the keyword expansion facilities of your revision control system.)
The compiler and linker will then conspire to get these strings into
the resulting binary. You could use the 'strings' command to get them
However, the 'ident' command does this one better. See the ident manpage.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!