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
- From: Daniel Jacobowitz <drow at false dot org>
- To: Josh Keller <jkeller at keytechinc dot com>
- Cc: binutils at sourceware dot org, Reuben Johnston <rjohnston at keytechinc dot com>
- Date: Fri, 10 Mar 2006 17:51:15 -0500
- Subject: Re: ld includes entire archive (.a) when compiling .elf file
- References: <E736F3E26DE59146A2343541510255B56D22A3@mercury.keytechinc.com>
On Fri, Mar 10, 2006 at 05:46:07PM -0500, Josh Keller wrote:
> The map file says the archive member is included. However, I only make
> one call to an empty function (I'm testing to see what's included) in my
> main() called OSInitHookEnd (first line listed below). I'm not sure why
> it's pulling in the rest of the libucos_ii.a archive.
> -Josh
>
> The top of the map file is as follows:
Here's what is happening:
> $ more main.map
> Archive member included because of file (symbol)
>
> ucos_ii/libucos_ii.a(os_cpu_c.o)
> main.o (OSInitHookEnd)
main.o includes os_cpu_c.o to define OSInitHookEnd.
> ucos_ii/libucos_ii.a(os_core.o)
> ucos_ii/libucos_ii.a(os_cpu_c.o)
> (OSIntCtxSwFlag)
os_cpu_c.o includes os_core.o to define OSIntCtxSwFlag.
> ucos_ii/libucos_ii.a(os_mem.o)
> ucos_ii/libucos_ii.a(os_core.o)
> (OS_MemInit)
Which includes os_mem.o to define OS_MemInit.
Et cetera.
Have you verified that the linker is receiving --gc-sections, as
I suggested? Also, did you build with -ffunction-sections and
-fdata-sections? If you want --gc-sections to be useful, you'll
have to put functions and variables into their own discardable
sections.
--
Daniel Jacobowitz
CodeSourcery