This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Reducing shared object file size
- From: Andrew Haley <aph at redhat dot com>
- To: Marcus Clyne <maccaday at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 05 May 2009 11:05:07 +0100
- Subject: Re: Reducing shared object file size
- References: <49FF6065.5060709@gmail.com>
Marcus Clyne wrote:
> 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?
This isn't really to do with gcc, but the linker.
Can I suggest that you have a look with objdump and readelf? I don't have
your file, so I can't see what's in it.
Andrew.