ld includes entire archive (.a) when compiling .elf file - working

Josh Keller jkeller@keytechinc.com
Sat Mar 11 04:10:00 GMT 2006


Ok.  Thanks Daniel!  I've got it working.  To reduce code size of your
executable:

1.  Compile all your libraries, etc, with the following cflags:

-ffunction-sections -fdata-sections

2.  Add the following switch to your linker flags (before any -l or -L
library includes):

-gc-sections

3.  At the top of your Cstartup.s or crt0.s file, place the following
entry point:

        .global _startup
        .func   _startup
_startup:

4.  In your linker file, at the top, let it know your entry point into
the code:

ENTRY(_startup)

Recompile your code, and it will automagically remove the sections that
are not being used.

-Josh



More information about the Binutils mailing list