Minimalist executable

S

Sam

Hello,

I am programming for Windows, using MinGW (GCC 3.2.3) and I have just read
"Techniques for reducing Executable size"
(http://www.catch22.org.uk/tuts/minexe.asp). I want to write the smallest
program with gcc, and I will use neither command line arguments (argc and
argv) nor memory functions (malloc, ...) (I will take advantage of
HeapAlloc) nor exception handling so that I do need the functions that are
called before main(). As a consequence I just wote

int mainCRTStartup()
{
return 0;
}

which is exactly 2 048 bytes, telling the linker I did not want any standard
or startup library.

I would like to get even smaller executables, by changing the FILEALIGN and
ALIGN of the executable, as explained in catch22's article. They use, for
Visual C++ 6.0 :

//---------------
// Make section alignment really small
#pragma comment(linker, "/FILEALIGN:16")
#pragma comment(linker, "/ALIGN:16")

// Merge sections
#pragma comment(linker, "/MERGE:.rdata=.text")
#pragma comment(linker, "/MERGE:.text=.text")
#pragma comment(linker, "/MERGE:.reloc=.text")
//---------------

How could I "translate" this for the MinGW linker ?

Thanks,
Sam.
 
D

Daniel Haude

On Fri, 15 Aug 2003 14:34:56 +0200,
in Msg. said:
I want to write the smallest program with gcc,

That's off-topic in comp.lang.c. Please try to limit this thread to
comp.os.ms-windows.programmer.misc where it belongs (f'up set)

--Daniel
 
S

Sven Semmler

Sam said:
int mainCRTStartup()
^

In C you need to write "(void)".
#pragma comment(linker, "/MERGE:.rdata=.text")
#pragma comment(linker, "/MERGE:.text=.text")
#pragma comment(linker, "/MERGE:.reloc=.text")
//---------------

How could I "translate" this for the MinGW linker ?

Search a group or mailing list for that compiler, since this is about the
linker not the C language.

/Sven
 
M

Mark McIntyre

Hello,

I am programming for Windows, using MinGW (GCC 3.2.3) and I have just read
"Techniques for reducing Executable size" .....
I would like to get even smaller executables, by changing the FILEALIGN and
ALIGN of the executable, as explained in catch22's article. .....
How could I "translate" this for the MinGW linker ?

This has /ABSOLUTELY/ nothing to do with C, you need to ask in a group
specialising in MinGW, whatever that is. Be prepared for
disappointment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top