This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ld includes entire archive (.a) when compiling .elf file
- From: "Josh Keller" <jkeller at keytechinc dot com>
- To: <binutils at sourceware dot org>
- Cc: "Reuben Johnston" <rjohnston at keytechinc dot com>
- Date: Fri, 10 Mar 2006 16:57:26 -0500
- Subject: ld includes entire archive (.a) when compiling .elf file
I'm trying to compile a .elf file with the following command line:
Linking: main.elf
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
--no-whole-archive --gc-sections -Iucos_ii
-Lucos_ii -lucos_ii -TAT91SAM7S64-ROM.ld
And I get an executable that runs, however, my binary is much larger
than it is supposed to be because the linker is including all the .o
files in my archive (.a).
I can't figure out what to do. I have tried the --gc-sections option
and the --no-whole-archive option but I still get a really large
executable. I created my archive from .o files using
arm-elf-ar -rcv libucos_ii.a $(OBJS).
I can't seem to figure out a good solution. Any ideas? I'd rather not
create an archive file for each .o file (which sort of defeats the
purpose of having a .a file) Thanks for the help!
I'm using GNU ld version 2.14 20030612
Here is a listing of the files in my archive:
$ arm-elf-size libucos_ii.a
text data bss dec hex filename
4156 0 0 4156 103c os_core.o (ex libucos_ii.a)
208 0 0 208 d0 os_cpu_c.o (ex libucos_ii.a)
0 0 0 0 0 os_flag.o (ex libucos_ii.a)
1168 0 0 1168 490 os_mem.o (ex libucos_ii.a)
2472 0 0 2472 9a8 os_q.o (ex libucos_ii.a)
3360 0 0 3360 d20 os_task.o (ex libucos_ii.a)
368 40 0 408 198 os_cpu_a.o (ex libucos_ii.a)
2 0 0 2 2 os_dbg_r.o (ex libucos_ii.a)
1564 0 0 1564 61c os_mbox.o (ex libucos_ii.a)
2256 0 0 2256 8d0 os_mutex.o (ex libucos_ii.a)
1252 0 0 1252 4e4 os_sem.o (ex libucos_ii.a)
764 0 0 764 2fc os_time.o (ex libucos_ii.a)
-Josh