AnsweredAssumed Answered

ffunction-sections is not working?

Question asked by Fco. Javier Rodriguez G on Jul 1, 2017
Latest reply on Aug 4, 2017 by Fco. Javier Rodriguez G

In order to decrease the program's  I want to use the linker flag -ffunction-sections, besides -gc-sections. Without -ffunction-sections flag the size of a binary output for freertos_blinky demo for the lpc11u68 is 18KB! It seems all functions are been included from the chip library even when they are not used. However I cannot use -ffunction-sections flag because a linker error:

 

/usr/local/mcuxpressoide-10.0.0_344/ide/tools/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: -f may not be used without -shared

 

From the command line the linker instruction seems to be:

make -r -j2 all
Building target: freertos_blinky.axf
Invoking: MCU Linker

arm-none-eabi-gcc -nostdlib -L"/home/fjrg76/Documents/MCUXpresso_10.0.0_344/workspace3/lpc_chip_11u6x/Debug" -L"/home/fjrg76/Documents/MCUXpresso_10.0.0_344/workspace3/lpc_board_nxp_lpcxpresso_11u68/Debug" -Xlinker -Map="freertos_blinky.map" -Xlinker --gc-sections -Xlinker --allow-multiple-definition -flto -Os -mcpu=cortex-m0plus.small-multiply -mthumb -T "freertos_blinky_Debug.ld" -o "freertos_blinky.axf" ./freertos/src/FreeRTOSCommonHooks.o ./freertos/src/heap_3.o ./freertos/src/list.o ./freertos/src/port.o ./freertos/src/queue.o ./freertos/src/tasks.o ./example/src/aeabi_romdiv_patch.o ./example/src/cr_startup_lpc11u6x.o ./example/src/crp.o ./example/src/freertos_blinky.o ./example/src/mtb.o ./example/src/sysinit.o -llpc_board_nxp_lpcxpresso_11u68 -llpc_chip_11u6x

Finished building target: freertos_blinky.axf

make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "freertos_blinky.axf"; # arm-none-eabi-objcopy -O binary "freertos_blinky.axf" "freertos_blinky.bin" ; checksum -p LPC11U68 -d "freertos_blinky.bin";
text data bss dec hex filename
18060 8 1072 19140 4ac4 freertos_blinky.axf

 

If I turn on the shared flags other problems shows up. And optimizing for size only saves 3KB, from 18KB to 15KB. Any ideas?

 

Thank you!

Outcomes