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
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
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
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