This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: ld includes entire archive (.a) when compiling .elf file - working
- From: "Josh Keller" <jkeller at keytechinc dot com>
- To: "Daniel Jacobowitz" <drow at false dot org>
- Cc: <binutils at sourceware dot org>, "Reuben Johnston" <rjohnston at keytechinc dot com>, "Bill Gatliff" <bgat at billgatliff dot com>
- Date: Fri, 10 Mar 2006 23:10:06 -0500
- Subject: 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