I compare three compilers:
- GCC (x86) from Debian (6.3.0) produces hugo_x86.so with 7.8K,
- GCC (ppc) from Codesourcery (4.6.0) produces hugo_46.so with 6.6K,
- GCC (x86) from Buildroot 2017.08 (7.2.0) produces hugo.so with 7.5K,
- GCC (ppc) from Buildroot 2017.08 (7.2.0) produces hugo.so with 67K,
- GCC (ppc) from Buildroot 2017.08 (6.4.0) produces hugo.so with 67K and
- GCC (ppc) from Buildroot 2017.08 (4.9.4) produces hugo.so with 67K
The code was taken from eli.thegreenplace.net:
int myglob = 42;
int ml_func(int a, int b)
{
myglob += a;
return b + myglob;
}
I ve compiled all sources like this:
powerpc-linux-gcc -c -o hugo.o hugo.c
powerpc-linux-gcc --shared -o hugo.so hugo.o
The difference between the files seems to be a padding (hexdump hugo.so | wc -l
):
- Debian (6.3.0): 381 lines
- Codesourcery (4.6.0): 283 lines
- Buildroot 2017.08 (7.2.0): 298 lines
- Buildroot 2017.08 (6.4.0): 294 lines
(objdump -s
shows a similar result)
Questions:
- How can I analyze the difference in the Object file best? (objdump, readelf, etc)
- How can I analyze the difference (e.g. default options) of the compiler best? (e.g. -dumpspecs)
- What could be the reason, for blowing up the shared object? How to increase the file size?
Thanks!
--
Edit:
It is also independent of the GCC specs. I ve dumped (-dumpspec
) the spec of the Codesourcery (4.6.0) GCC which produces a small shared object, and used it with the Buildroot GCC (-specs
) and got again a 67K shared object.