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


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


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