Reducing the size of C++ executables - eliminating malloc

jschopp jschopp@austin.ibm.com
Tue Nov 14 13:32:00 GMT 2006


 > GCC 4.1.1 for PowerPC generates a 162K executable for a
 > minimal program  "int main() { return 0; }".  GCC 3.4.1
 > generated a 7.2K executable.  Mark Mitchell mentioned the
 > same problem for ARM and proposed a patch to remove the
 > reference to malloc in atexit
 > (http://sourceware.org/ml/newlib/2006/msg00181.html).

We've seen this on cell spu as well. And with only 256K total memory it was a really big 
deal for us.  Our minimal program dropped from 10566 bytes to 2822 bytes (text + data + 
bss) with the attached completely unacceptable for merging patch.  We were thinking that 
our platform has no need for more than 32 atexit handlers, and the proper solution is to 
make the code removed in the attached patch simply #ifdefed away for platforms like ours 
that are happy with 32 atexit handlers and are short on space.  This seems to be the 
approach in the patch you linked to.

-Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atexithack.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20061114/c2f371fa/attachment.bin>


More information about the Newlib mailing list