Hi..

I've come across a, for me, strange behavior of the ml/link combo...

I wrote a small dll and during the development the dll size kept at a constant size of 3.072 bytes.. it didn't change by putting more code in or cutting some out (well.. eventually it would change, of course)..

Even Iczelion's tutorial #2 compiles at 2.560 bytes, whereas s/he writes that on the used machine it compiled at 1.536 bytes.

Examined with a hexeditor one can see that the binary is filled with '00' bytes... as padding obviously...

Now I wonder, is there a way to cut that padding down? I mean, of course 3k or 2k is not really big... but still it bugs me when I know that it should be possible to cut it down... :)

Any ideas?
- Thomas
Posted on 2003-01-25 16:03:56 by TAF
Use PE realigner.
Posted on 2003-01-25 16:10:44 by comrade
> Use PE realigner.

I've googled a bit for those and there are quite a lot of those... any recommendations?

So there's nothing one can do (switches, directives, etc.) with the tools provided (ml, link, etc.)?

- Thomas
Posted on 2003-01-25 16:45:54 by TAF


So there's nothing one can do (switches, directives, etc.) with the tools provided (ml, link, etc.)?

- Thomas


What about the /ALIGN switch? :)
Posted on 2003-01-25 19:10:29 by bazik
What about the /ALIGN switch?


It spits out a warning (LINK : warning LNK4108: /ALIGN specified without /DRIVER or /VXD; image may not run) but the linked dll seems to work and is much smaller indeed... from 3.072 down to 1.216.. :)
I chose /ALIGN:64 is that ok? what would be a good value?

So, in most cases(?), I can disregard that warning ?

Thanks for that /ALIGN hint...
- Thomas
Posted on 2003-01-26 03:32:37 by TAF
TAF,

be careful with alignment, the default with the linker in MASM32 is 512 bytes and if you go under that, the image will probably not run. The zero padding is to maintain section alignment so there is not a lot that can be done about it.

What may be worth a try is to combine the sections in the DLL as you may get a size reduction this way but be sure to test it on the later versions of Windows as they can be a bit piggy about changes of this type.

Have a look at the /MERGE option.

Regards,

hutch@movsd.com
Posted on 2003-01-27 12:07:03 by hutch--
Hi Hutch..

The Alignment.. yeah.. although everything worked I had a weird feeling about that small alignment.. and eventually resigned to the fact that MASM must have chosen that alignment and displayed that warning with good reason... so I switched back to the default...

Will look into that /MERGE switch...

Still I find that padding (in the file) strange.. :)

Thanks..
- Thomas
Posted on 2003-01-27 16:18:13 by TAF