Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Minimalist executable

Reply
Thread Tools

Minimalist executable

 
 
Sam
Guest
Posts: n/a
 
      08-15-2003
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.



 
Reply With Quote
 
 
 
 
Daniel Haude
Guest
Posts: n/a
 
      08-15-2003
On Fri, 15 Aug 2003 14:34:56 +0200,
Sam <(E-Mail Removed)> wrote
in Msg. <3f3cd373$0$26422$(E-Mail Removed)>

> 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

--
"With me is nothing wrong! And with you?" (from r.a.m.p)
 
Reply With Quote
 
 
 
 
Sven Semmler
Guest
Posts: n/a
 
      08-15-2003
Sam wrote:

> 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

--
Sven Semmler http://www.semmlerconsulting.com/
GPG Fingerprint: 72CA E26D C2A3 1FEB 7AFC 10EA F769 A9A4 937F 5E67
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      08-15-2003
On Fri, 15 Aug 2003 14:34:56 +0200, in comp.lang.c , "Sam"
<(E-Mail Removed)> wrote:

>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.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OT] minimalist web server Daniel Fetchinson Python 12 12-03-2007 09:27 AM
Tiny/small/minimalist Python? rtk Python 16 07-06-2007 05:02 PM
Very Simple, Minimalist Technique For OOP in C... Chris Thomasson C Programming 10 06-24-2007 07:53 PM
minimalist regular expression borges2003xx@yahoo.it Python 10 08-26-2005 07:12 PM
Use Cases -- A minimalist's View Uncle Bob (Robert C. Martin) Java 0 07-02-2003 02:45 PM



Advertisments