From 0a1db4b00c949a91ec5d0a9dade76f201700cb6c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 2 Mar 2023 12:47:05 -0800 Subject: [PATCH] Demo/CORTEX_M3_MPS2_QEMU_GCC: Fix use of -ffunction-sections -fdata-sections For these options to be of any use, they must be passed to the compiler when building object files and then the --gc-sections flag must be passed to the linker. Add -ffunction-sections -fdata-sections to CFLAGS and then add -Wl,--gc-sections to LDFLAGS. Signed-off-by: Keith Packard --- FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/Makefile b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/Makefile index bc7b74c461..9b5f240b99 100644 --- a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/Makefile +++ b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/Makefile @@ -68,10 +68,12 @@ DEFINES := -DQEMU_SOC_MPS2 -DHEAP3 LDFLAGS = -T ./scripts/mps2_m3.ld -specs=nano.specs --specs=rdimon.specs -lc -lrdimon LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map +LDFLAGS += -Wl,--gc-sections CFLAGS += -nostartfiles -mthumb -mcpu=cortex-m3 -Wno-error=implicit-function-declaration CFLAGS += -Wno-builtin-declaration-mismatch -Werror CFLAGS += -Wall -Wextra +CFLAGS += -ffunction-sections -fdata-sections ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 -Og @@ -88,7 +90,7 @@ CFLAGS += $(INCLUDE_DIRS) .PHONY: clean $(BUILD_DIR)/$(BIN) : $(OBJ_FILES) - $(CC) -ffunction-sections -fdata-sections $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@) %.d: %.c @set -e; rm -f $@; \