small exe size increase from 1.7.0-62 to -63

View: New views
5 Messages — Rating Filter:   Alert me  

small exe size increase from 1.7.0-62 to -63

by Andy Koppe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A test with an empty main compiled using gcc-4 under cygwin-1.7.0-63
has a size of 6.5K. After downgrading to 1.7.0-62, without changing
anything else, the size goes down to 5.0K.

$ cat test.c
int main(void)
{
  return 0;
}
$ gcc test.c -Os -s

Looking at objdump differences, both code and data size have gone up:

< SizeOfCode            00000800
< SizeOfInitializedData 00001000
---
> SizeOfCode            00000e00
> SizeOfInitializedData 00001600

And we're pulling in a bunch of additional functions from cygwin1.dll
and kernel32.dll:

>       515c      666  abort
>       5170      788  cygwin_create_path
>       51b0      812  dll_dllcrt0
>       51d4     1221  memcpy
>       51ec     1620  strlen
>       51f8     1742  vsnprintf

>       5238      336  GetModuleFileNameW
>       5274      388  GetStdHandle
>       5284      798  VirtualProtect
>       5296      801  VirtualQuery
>       52a6      827  WriteFile

Obviously 1.5K isn't much of a concern, but is this expected?

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: small exe size increase from 1.7.0-62 to -63

by Corinna Vinschen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov  6 06:18, Andy Koppe wrote:

> A test with an empty main compiled using gcc-4 under cygwin-1.7.0-63
> has a size of 6.5K. After downgrading to 1.7.0-62, without changing
> anything else, the size goes down to 5.0K.
>
> $ cat test.c
> int main(void)
> {
>   return 0;
> }
> $ gcc test.c -Os -s
>
> Looking at objdump differences, both code and data size have gone up:
>
> < SizeOfCode            00000800
> < SizeOfInitializedData 00001000
> ---
> > SizeOfCode            00000e00
> > SizeOfInitializedData 00001600
>
> And we're pulling in a bunch of additional functions from cygwin1.dll
> and kernel32.dll:
>
> >       515c      666  abort
> >       5170      788  cygwin_create_path
> >       51b0      812  dll_dllcrt0
> >       51d4     1221  memcpy
> >       51ec     1620  strlen
> >       51f8     1742  vsnprintf
>
> >       5238      336  GetModuleFileNameW
> >       5274      388  GetStdHandle
> >       5284      798  VirtualProtect
> >       5296      801  VirtualQuery
> >       52a6      827  WriteFile
>
> Obviously 1.5K isn't much of a concern, but is this expected?

It's a result of the new pseudo reloc v2 support.  Probably Chuck can
explain this better.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: small exe size increase from 1.7.0-62 to -63

by Charles Wilson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andy Koppe wrote:

>>       515c      666  abort
>>       5170      788  cygwin_create_path
>>       51b0      812  dll_dllcrt0
>>       51d4     1221  memcpy
>>       51ec     1620  strlen
>>       51f8     1742  vsnprintf
>
>>       5238      336  GetModuleFileNameW
>>       5274      388  GetStdHandle
>>       5284      798  VirtualProtect
>>       5296      801  VirtualQuery
>>       52a6      827  WriteFile
>
> Obviously 1.5K isn't much of a concern, but is this expected?

Yes. Most of these are from the new v2 pseudo-reloc runtime support.

--
Chuck


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: small exe size increase from 1.7.0-62 to -63

by Charles Wilson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Corinna Vinschen wrote:
>> Obviously 1.5K isn't much of a concern, but is this expected?
>
> It's a result of the new pseudo reloc v2 support.  Probably Chuck can
> explain this better.

I guess I should keep my reader in thread mode...I don't know what I
could add to Corinna's explanation, except to say that all DLLs and EXEs
include the startup code for runtime pseudo-relocs.  It now handles both
v1 and v2 versions -- and the v2 version requires additional code
(there's [some of] your 1.5k). Also, there is now actual error handling,
so that's the WriteFile and various string handling imports. Finally, in
both v1 and v2 mode, we now use the Virtual* functions to temporarily
mark read-only pages writeable in order to update the relocs.

This *should* make it possible -- **later** -- to reverse the current
binutils behavior on cygwin when --enable-auto-import.  Right now, in
that situation, binutils merges .rdata with .data, and marks .text
writable, which is...less than ideal.

--
Chuck

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: small exe size increase from 1.7.0-62 to -63

by Kai Tietz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/6 Charles Wilson <cygwin@...>:

> Corinna Vinschen wrote:
>>> Obviously 1.5K isn't much of a concern, but is this expected?
>>
>> It's a result of the new pseudo reloc v2 support.  Probably Chuck can
>> explain this better.
>
> I guess I should keep my reader in thread mode...I don't know what I
> could add to Corinna's explanation, except to say that all DLLs and EXEs
> include the startup code for runtime pseudo-relocs.  It now handles both
> v1 and v2 versions -- and the v2 version requires additional code
> (there's [some of] your 1.5k). Also, there is now actual error handling,
> so that's the WriteFile and various string handling imports. Finally, in
> both v1 and v2 mode, we now use the Virtual* functions to temporarily
> mark read-only pages writeable in order to update the relocs.
>
> This *should* make it possible -- **later** -- to reverse the current
> binutils behavior on cygwin when --enable-auto-import.  Right now, in
> that situation, binutils merges .rdata with .data, and marks .text
> writable, which is...less than ideal.

Right, I can't say here more about it. Maybe one point is here of some
interest about version 2 relocation, too. The DLLs/EXE files linking
via pseudo-relocations to an DLL having much smaller PE-headers. This
has positive side-effect on startup time and to size of the physical
application size. Btw upcoming binutils (cvs head version) is modified
already to use version 2 for x86 targets by default.

Cheers,
Kai


--
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple