News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Size is always 2-3KB

Started by 2-Bit Chip, August 29, 2009, 11:05:34 PM

Previous topic - Next topic

2-Bit Chip

Just this simple code makes 2 bytes (1,536 bytes):


.486
.model stdcall, flat
option casemap:none

include \masm32\include\kernel32.inc

includelib \masm32\lib\kernel32.lib

.code

fStart:
    invoke ExitProcess, 0h
   
end fStart


Shouldn't it be no more than 1,024 bytes? Could I get it down around 500 bytes, and still keep the same speed or make it much faster (that would be great!)

dedndave

how fast do you want to exit ? - lol
you can get it down - probably not to 512 bytes, though
in the masm32\bin folder, you should find PoLink
if not, google "Pelles C" or "PoAsm" or "Pelles Assembler" and get his linker
it seems to make smaller exe's

ecube

you can merge the import table to the code section using the linker switch " /MERGE:.data=.text /ALIGN:4"

most the size comes from the creation of the import table, which is required to run on 2k I believe, and btw 1024 is considered the smallest "legal" pe file.If you want to remove the import table use  a simple "ret" at the end to exit, which may crash the application instead idk.

2-Bit Chip

that's a good way to exit an application—crash it lol :lol

hutch--

1024 bytes is the correct minimum, the first 512 byte section is the PE and MZ header, the second contains any code. Look in the MASM32 examples for a 1k window.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

E^Cube:
i have a test program that is 5632 bytes with "/SUBSYSTEM:CONSOLE /OPT:NOREF"
i tried adding "/MERGE:.data=.text /ALIGN:4"

LINK : warning LNK4108: /ALIGN specified without /DRIVER or /VXD; image may not run
errtest.obj : fatal error LNK1164: section 0x1 alignment (16) greater than /ALIGN value

no obj file was created
so i changed it to "/ALIGN:16"

LINK : warning LNK4108: /ALIGN specified without /DRIVER or /VXD; image may not run
LINK : warning LNK4078: multiple ".text" sections found with different attributes (C0000040)

the exe is now 5024 bytes and seems to run ok
then, i took the ALIGN out altogether and just used "/MERGE:.data=.text"

LINK : warning LNK4078: multiple ".text" sections found with different attributes (C0000040)

the file is 5120 bytes and also seems to run ok

thanks for the info
it is a program that captures error information and i use the IAT tables for info
i may have to add a little code to make it work correctly with these options - lol
good to know they are there   :U

KhipuCoder

Hi
2-Bit Chip,

This will do the trick:

/FILEALIGN:0x200 /MERGE:.data=.text /MERGE:.rdata=.text /SECTION:.text,RWE


HTH

KhipuCoder