delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/06/29/03:16:33

Date: Thu, 29 Jun 2000 10:01:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mark E." <snowball3 AT bigfoot DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: is it possible to use strip option in call to compiler (fwd)
In-Reply-To: <395A2F50.7422.1F2BA3@localhost>
Message-ID: <Pine.SUN.3.91.1000629100055.9718L-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 28 Jun 2000, Mark E. wrote:

> Compile a trivial program to an object file. Now compile that program to an 
> executable, but leave out the '.exe':
> 
> gcc -o trivial trivial.o
> 
> strip trivial.exe and you will find that trivial and trivial.exe are exactly 
> the same size.

Yes, that's what I saw also.  The size is the same because trivial has
extra 2KB of garbage prepended to it, whereas trivial.exe has the stub
in that place.

However, I'm not sure where does this (and the other facts you
described) leave us.  As far as I understand, you can explain why the
garbage gets stripped in some situations but not in the others, but
what program is responsible for adding the garbage in the first place?
It looks like it's the linker, according to your testing, right?

> If you use ld and bypass stubify and djgpp.djl, you will also get just about 
> the same file size.

Is bypassing djgpp.djl important here?  I think it isn't, because the
garbage gets added with or without it.

> When you run strip on a stubified file, it knows enough about 
> placement and alignment (though I'm sure not like ld does) to get rid of the 
> 2K. I suspect strip writes out the stripped file based on the section's vma. 

So you are saying that "ld -s" and "strip" strip the program
differently, as far as the source code of the two programs goes?  Even
if so, I'd expect the two ways to be equivalent in the effect they
produce.

> Putting readable garbage in the executable is not acceptable IMO no
> matter what the cause.

Agreed.  What I usually see in that garbage is left-overs from files
that were removed (temporary files used by other tools etc.).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019