Mail Archives: djgpp-workers/2000/06/29/03:16:33
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 -