Yes, I am using -Wl,--gc-sections. Following are the exact flags I am using:
Without LTO: COMPILE: arm-none-eabi-gcc -c -o main.o -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb main.c
LINK: arm-none-eabi-gcc -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -T xip.ld -nostartfiles -Xlinker -M -Xlinker -Map=hello_world.map -Xlinker --cref -Xlinker --gc-sections -Xlinker --start-group main.o -Xlinker --end-group -o hello_world.axf
With LTO: COMPILE: arm-none-eabi-gcc -c -o main.o -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -flto -ffat-lto-objects main.c
LINK: arm-none-eabi-gcc -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -flto -ffat-lto-objects -T xip.ld -nostartfiles -Xlinker -M -Xlinker -Map=hello_world.map -Xlinker --cref -Xlinker --gc-sections -Xlinker -flto -Xlinker --start-group main.o -Xlinker --end-group -o hello_world.axf
Please let me know what I am missing here.
Yes, I am using -Wl,--gc-sections. Following are the exact flags I am using:
Without LTO:
COMPILE:
arm-none-eabi-gcc -c -o main.o -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb main.c
LINK: world.map -Xlinker --cref -Xlinker --gc-sections -Xlinker --start-group main.o -Xlinker --end-group -o hello_world.axf
arm-none-eabi-gcc -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -T xip.ld -nostartfiles -Xlinker -M -Xlinker -Map=hello_
With LTO:
COMPILE:
arm-none-eabi-gcc -c -o main.o -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -flto -ffat-lto-objects main.c
LINK: world.map -Xlinker --cref -Xlinker --gc-sections -Xlinker -flto -Xlinker --start-group main.o -Xlinker --end-group -o hello_world.axf
arm-none-eabi-gcc -Wall -g -Os -MMD -ffunction-sections -fdata-sections -fno-common -ffreestanding -mcpu=cortex-m4 -mthumb -flto -ffat-lto-objects -T xip.ld -nostartfiles -Xlinker -M -Xlinker -Map=hello_
Please let me know what I am missing here.