delorie.com/archives/browse.cgi | search |
Sender: | mike AT Home-51 DOT inp DOT nsk DOT su |
To: | djgpp AT delorie DOT com |
Subject: | Re: Excessive exe sizes |
References: | <01bcf777$71921820$56f682c1 AT nicland> |
<6587ak$f53 AT examiner DOT concentric DOT net> | |
From: | Michael Bukin <bukinm AT inp DOT nsk DOT su> |
Date: | 23 Nov 1997 13:54:10 +0600 |
In-Reply-To: | "DigitalFX"'s message of Sat, 22 Nov 1997 22:18:20 -0500 |
Message-ID: | <m3g1oof3kt.fsf@H-Bukin.inp.nsk.su> |
Lines: | 29 |
"DigitalFX" <digifx AT concentric DOT net> writes: > >When I compile my program it produces an excessive .exe - 2.7Mb from source > >files of about 40Kb! The .o file is 2.6Mb. When I looked at the .exe and > >the .o I found they were mostly blank space. > > You can use STRIP and DJP to get the filesize down. Or use function with `constructor' attribute to generate array at startup. But this solution is gcc specific. int* array; void array_ctor (void) __attribute__ ((__constructor__)); void array_ctor (void) { array = (int*) malloc (100 * sizeof (int)); /* Test returned pointer and initialize array here. */ } I'm sure that it is safe to call malloc or new in constructor, but the only way to be sure is to look in gcc sources (or ask gcc developers). Read about function attributes with: info gcc "c ext" "function attr"
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |