This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -ffunction-sections -fdata-sections have no effect


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Valentin Longchamp schreef:
> Hello Kristof,
> 
>> A couple of ideas:
>> Did you remember to use -gc-sections when linking?
>> Did you strip the binary?
> 
> Yes I did use the -gc-sections option when linking. What do you mean by "strip 
> the binary" ?
> 
>> What's your output data format? Are you creating ELF files? Not all
>> output formats support arbitraty sections.
>>
> 
> Yep, I'm creating ELF files. Is it a problem to do it with ELF files ? I 
> wouldn't think so.
> 
> By the way, I thought that if my toolchain isn't compiled with 
> both -ffunction-sections -fdata-section options, it isn't going to 
> be "separated" at the beginning and that's why I always get the same huge 
> binary when I compile my program static with or without the section options. 
> So I added the following option to my crosstool script:
> 
>> EXTRA_TARGET_CFLAGS="-mabi=aapcs-linux -ffunction-section -fdata-section"
>> export EXTRA_TARGET_CFLAGS
> 
> However, using this, I get segfaulting binaries. Where should I add these 
> options so that my glibc is built with these options ? Maybe I should add it 
> to the GLIBC_EXTRA_CONFIG variable ?
> 
> Thank you
> 
> Valentin

ELF definitely supports these options. We're also using them with fairly
good results.

Stripping the binary means remove all unneeded sections. The ELF binary
generated by gcc usually contains debugging information and such which
is not needed to run. The 'strip' tool removes this, significantly
reducing the size of the binary. The tools should be part of binutils,
so chances are you've already got it installed.

The readelf and nm tools (also part of binutils) can help to analyze the
ELF files and determine what parts are biggest. (readelf -e <elf file>)

You shouldn't need any special options during the compilation of your
toolchain to get these reduced sizes. You do need them during the
compilation of your software of course.

Kristof



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFNfujUEZ9DhGwDugRA/FlAJ4mVVMNFKmbt/88FBy/gvJblgAFDgCeNEhn
JMCBOArFJkhCJ41YWoJ8eqM=
=4ahN
-----END PGP SIGNATURE-----

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]