2006-06-05 11:52 PM
2006-06-05 06:14 AM
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, Madis2006-06-05 08:10 PM
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. ben2006-06-05 10:17 PM
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. Madis2006-06-05 10:57 PM
ok, just checked my settings I also have
--gc-section added to the linker options, you might want to try that2006-06-05 11:28 PM
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 sjo2006-06-05 11:46 PM
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...? Madis2006-06-05 11:52 PM
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