I compare three compilers:
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):
(objdump -s shows a similar result)
Questions:
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.
from How to reduce ELF section padding?:
It looks like this is due to binutils 2.27 increasing the default page size of PowerPC targets to 64k, resulting in bloated binaries on embedded platforms.
There's a discussion on the crosstool-NG github here.
Configuring binutils with --disable-relro should improve things.
You can also add -Wl,-z,max-page-size=0x1000 to gcc when compiling.
When adding BR2_BINUTILS_EXTRA_CONFIG_OPTIONS="--disable-relro" to my buildroot configuration, the share object size is reduced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With