This is the mail archive of the
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?
I am developing elf linker for the PicoBlaze CPU target using
elfutils-0.152 (see work-in-progress patches in ). 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
I've discovered that the option --gc-sections does not work as
intended (see test examples in  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  I tried it also with GNU binutils and
it works fine.
Some commands from  - 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?
Space--the final frontier!