LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Embedding comments into a binary.

[ILUG] Embedding comments into a binary.

Kenn Humborg kenn at bluetree.ie
Thu Dec 7 19:04:14 GMT 2000


> 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
> etc.

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 1.2.3.4";

(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
out again.

However, the 'ident' command does this one better.  See the ident manpage.

Later,
Kenn





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell