This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
--gc-sections not working?
- From: Jaroslav Sýkora <jaroslav.sykora at gmail.com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 13 Jan 2012 16:53:27 +0100
- Subject: --gc-sections not working?
Hello everybody!
I am developing elf linker for the PicoBlaze CPU target using
elfutils-0.152 (see work-in-progress patches in [1]). PicoBlaze is a
primitive 8-bit RISC core for Xilinx FPGA. It has quite a small
program memory - only 1024 instructions. Hence code size is of primary
concern here.
I've discovered that the option --gc-sections does not work as
intended (see test examples in [2] using i386 target instead). I put
each function in its own section (-ffunction-sections), but when a
single function (section .text.foo) from the object file is included
in the output, all the other sections (.text.bar) are included too. I
also tried linking against an archive: in this case the situation
improves as untouched object files in the archive are not linked in,
but once a function is linked-in, all the other from the same object
file are linked-in too. In [2] I tried it also with GNU binutils and
it works fine.
Some commands from [2] - maybe I am missing an option switch somewhere?
gcc -Wall -O3 -ffunction-sections -m32 -c -o main.o ../src/main.c
elfutils-ld -c elf32-i386.script --gc-sections -L. main.o -lmy -o fin-lib-gc.elf
I very much need the feature to omit unused functions to minimize code size.
Could someone help please?
Bye,
Jara
[1] http://dl.dropbox.com/u/3124266/elfutils-0.152-pblaze-20120112.patch
[2] http://dl.dropbox.com/u/3124266/elfutils-test.tar.gz
--
Space--the final frontier!