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: "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>
- Date: Fri, 10 Mar 2006 18:08:53 -0500
- Subject: RE: ld includes entire archive (.a) when compiling .elf file
How will specifying the start of execution with (-e) remove the uncalled
functions and unused variables? Does the ld linker even have the
capability to automatically remove uncalled functions without having to
specify each used section? I'm sorry if I sound really confused, I'm
pretty new to this. Thanks for your patience.
-Josh
-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@false.org]
Sent: Friday, March 10, 2006 6:02 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:59:32PM -0500, Josh Keller wrote:
> 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.
Then obviously you've passed it the wrong options... ah,
-ffunction-sections is not a linker option, it's a compiler option, so
no -Wl.
> 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
Try using the linker option -e to specify the function at the start of
execution.
--
Daniel Jacobowitz
CodeSourcery