cancel
Showing results for 
Search instead for 
Did you mean: 

GNU

planeetmaa
Associate II
Posted on June 06, 2006 at 08:52

GNU

7 REPLIES 7
planeetmaa
Associate II
Posted on June 05, 2006 at 15:14

Hi,

Im using GNU toolchain to compile my code. As I checked the mapfile, I noticed that object files are included entirely to my code from the libraries. My question is, is it possible to tell the linker not to include entire object file (all the functions specified in the object file) but only the functions which are used?

makefile section for linking looks as the following:

arm-elf-gcc ./src/startup.o ./src/asm.o ./src/INTERRUPT.o ./src/simple.o -mcpu=arm7tdmi -nostartfiles -T./prj/str7_ram.ld -Wl,-Map=test_lib.map,--cref,--no-warn-mismatch,-L../lib/,-lst,-lIbus -L../lib/ -lst -llcd -lIbus -o test_lib.elf

st lib is the library from ST webpage. But if I use UART_init, for example, all the UART related fuctions are present from the UART.c (libst.a(uart.o)).

Thank you for yor advice,

Madis

ben2
Associate II
Posted on June 06, 2006 at 05:10

you need to compile the libraries with

-ffunction-sections

the function name is then appended to the .text section name. you may need to tweak you linker file a little also.

ben

planeetmaa
Associate II
Posted on June 06, 2006 at 07:17

Hi,

I tested that --ffuncion-sections

The result was that every function was placed to different section (.text.UART_init, for example). Then linker complined that I dont have memory region specified for loadable section. I added

*(.text.*);

. = ALIGN(4);

to linker script right after the normal text section. But the result is the same, Im afraid. Somehow all the UART related functions get inserted to the output.

Madis

ben2
Associate II
Posted on June 06, 2006 at 07:57

ok, just checked my settings I also have

--gc-section

added to the linker options, you might want to try that

sjo
Associate II
Posted on June 06, 2006 at 08:28

Use -ffunction-sections and -fdata-sections and as mentioned the --gc-sections linker switch.

To get full benifit of this all libs need to be built with this, including gcc c libraries.

This is the standard setting for the Anglia arm toolchain.

Regards

sjo

planeetmaa
Associate II
Posted on June 06, 2006 at 08:46

Yes, thanks, it works.

But just for curiosity. I was not able to locate that option in the documentation (ld nor gcc). Whats the ''special meaning'' of that option and where is it documented...?

Madis

sjo
Associate II
Posted on June 06, 2006 at 08:52

You must have old manuals, the gcc info is:

3.10 Options That Control Optimization

and the ld info under:

2.1 Command Line Options

try doing a search for garbage collection

Regards

sjo