This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Reducing shared object file size
- From: Marcus Clyne <maccaday at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 04 May 2009 22:38:45 +0100
- Subject: Reducing shared object file size
Hi,
I'm wondering how I might be able to reduce the size of shared object
files I'm generating.
I'm using the following commands to generate my files:
gcc -fPIC -o file.o -c src.c (which produces a file
of around 1.5kb)
gcc -v -shared -o file.so file.o -lmylib (which produces a file of
around 5.9kb)
Since there are very few commands in my shared object (essentially two
or three calls to functions in libmylib), and because I've seen many
shared objects that are much smaller than 5.9kb, I feel I should be able
to reduce the .so file in size.
Can anyone give me suggestions as to how to do this? I've tried adding
-O2 and -O3 to both calls, and there's barely a difference in size.
Also, can anyone tell me what the 4.4kb of data is that represents the
difference between the two file sizes?
Thanks in advance,
Marcus.