Results 1 to 10 of 10

Thread: Extra "stuff" in compiled binary - why?

  1. #1
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    777
    Distro
    Kubuntu 14.04 Trusty Tahr

    Extra "stuff" in compiled binary - why?

    Hi all,

    I noticed that some text gets inserted into the binary files which result from compiling my C source.

    Unless I'm debugging, I want the smallest possible binary possible. The stuff I see appears to be useless (code-wise) as I can zero-overwrite it and the executable still works.

    Here's a screenshot of the text as seen in "hexedit":




    I've seen programs (pre-compiled binaries) from other sources that had no "advertising" in them.

    Is this unique to the Ubuntu release of GCC and G++?

    What does it mean? Why is it in there?

    And, is there a way to remove it?

    Thanks!

    -- Roger
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  2. #2
    Join Date
    Feb 2008
    Beans
    606
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Extra "stuff" in compiled binary - why?

    It's probably debugging info: run 'strip' on the file and see if it goes away.

    Note that debug info shouldn't be loaded into memory unless you need it, so it only really increases the size of the executable on disk, not in RAM.

  3. #3
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    777
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Extra "stuff" in compiled binary - why?

    Quote Originally Posted by movieman View Post
    It's probably debugging info: run 'strip' on the file and see if it goes away.

    Note that debug info shouldn't be loaded into memory unless you need it, so it only really increases the size of the executable on disk, not in RAM.
    No, it's not debug info. The file HAS debug info in it (and I know what it looks like).

    That "Ubuntu" stuff is even present in non debug, stripped "release" versions of a binary.
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  4. #4
    Join Date
    May 2007
    Beans
    245
    Distro
    Ubuntu 10.04 Lucid Lynx

    Lightbulb Re: Extra "stuff" in compiled binary - why?

    To eliminate all of the "extra stuff", you will want to generate the ELF header by hand. This tutorial will walk you through the details:

    http://www.muppetlabs.com/~breadbox/...ny/teensy.html

  5. #5
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    777
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Extra "stuff" in compiled binary - why?

    Quote Originally Posted by NathanB View Post
    To eliminate all of the "extra stuff", you will want to generate the ELF header by hand. This tutorial will walk you through the details:

    http://www.muppetlabs.com/~breadbox/...ny/teensy.html
    That's really interesting info... but not really the answer to the question.
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  6. #6
    Join Date
    Feb 2009
    Beans
    24

    Re: Extra "stuff" in compiled binary - why?

    Try "strip -R.comment myfile". (but if you *really* want a small file, follow Nathan's advice!)

    Best,
    Frank

  7. #7
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,274
    Distro
    Kubuntu

    Re: Extra "stuff" in compiled binary - why?

    Quote Originally Posted by movieman View Post
    It's probably debugging info: run 'strip' on the file and see if it goes away.

    Note that debug info shouldn't be loaded into memory unless you need it, so it only really increases the size of the executable on disk, not in RAM.
    Unless of course, the RAM is your "disk". Not all systems have a HDD.

  8. #8
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Extra "stuff" in compiled binary - why?

    It's just compiler information. Not "adverstising" and not particular to Ubuntu either...

  9. #9
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    777
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Extra "stuff" in compiled binary - why?

    Quote Originally Posted by nvteighen View Post
    It's just compiler information. Not "adverstising" and not particular to Ubuntu either...
    Well, in a roundabout way, I got my answer. The utility "strip" is what removes unnecessary things from executables.

    And, to remove the "advertising" (compiler information), "strip" is used like this:

    Code:
        strip -s -R .comment -R .gnu.version executable
    So, thanks everyone for the help and comments!

    -- Roger
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  10. #10
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    777
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Extra "stuff" in compiled binary - why?

    Quote Originally Posted by Frank Kotler View Post
    Try "strip -R.comment myfile". (but if you *really* want a small file, follow Nathan's advice!)

    Best,
    Frank
    At first I thought that was a GCC command line argument!

    It wasn't until later that I found out that "strip" is a separate program!

    -- Roger
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •