public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RE: ld includes entire archive (.a) when compiling .elf file - working
@ 2006-03-11  4:10 Josh Keller
  0 siblings, 0 replies; only message in thread
From: Josh Keller @ 2006-03-11  4:10 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: binutils, Reuben Johnston, Bill Gatliff

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-03-11  4:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-11  4:10 ld includes entire archive (.a) when compiling .elf file - working Josh Keller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).