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


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: ld includes entire archive (.a) when compiling .elf file - working


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


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