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


Building with --gc-sections ends up giving me a 0-byte binary.  It seems
to think all my code is garbage (See below) ;)  I'm guessing that I have
to subdivide my code somehow to tell it what to remove, etc.

I turned on the -f options and got the following error:
/usr/local/gnu/lib/gcc-lib/arm-elf/3.3/../../../../arm-elf/bin/ld: -f
may not be used without -shared.

Output from my compiler...

arm-elf-gcc  Cstartup.o   main.o Cstartup_SAM7.o irq.o pio.o
interrupt_pit.o interrupt_Usart.o --output main.elf -nostartfiles
-Wl,-Map=main.map,--cref,--gc-sections -Iucos_ii -Lucos_ii -lucos_ii
-TAT91SAM7S64-ROM.ld

Size after:
main.elf  :
section            size      addr
.text                 0         0
.data                 0   2097152
.bss                  0         0
.stab              4884         0
.stabstr          33758         0
.debug_aranges       96         0
.debug_pubnames      29         0
.debug_info        2524         0
.debug_abbrev       406         0
.debug_line         467         0
.debug_frame         32         0
.debug_str         1102         0
Total             43298 


Joshua Keller
Key Technologies, Inc.
40 East Cross Street
Baltimore, MD 21230
Phone:  410-385-0200
Fax:      410-385-1114
jkeller@keytechinc.com
www.keytechinc.com
 

Visit Key Tech at the MD&M East in NYC June 6-8, 2006  - - Booth# 1680 

Save $55 on your admission...go to Key Tech at MDM East


-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@false.org] 
Sent: Friday, March 10, 2006 5:51 PM
To: Josh Keller
Cc: binutils@sourceware.org; Reuben Johnston
Subject: 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]