diff --git a/boards/arm/stm32/photon/scripts/Make.defs b/boards/arm/stm32/photon/scripts/Make.defs index 0e7224660f9..6cafd40bfe6 100644 --- a/boards/arm/stm32/photon/scripts/Make.defs +++ b/boards/arm/stm32/photon/scripts/Make.defs @@ -43,8 +43,8 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing endif -ARCHCFLAGS = -fno-common -fno-builtin -ARCHCXXFLAGS = -fno-common -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHCFLAGS = -fno-common -fno-builtin -ffunction-sections -fdata-sections +ARCHCXXFLAGS = -fno-common -fno-builtin -fno-exceptions -fcheck-new -fno-rtti -ffunction-sections -fdata-sections ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -64,6 +64,8 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y) LDFLAGS += -g endif +LDFLAGS += --gc-sections + ifeq ($(CONFIG_DFU_BINARY),y) define FLASH diff --git a/boards/arm/stm32/stm32f4discovery/scripts/Make.defs b/boards/arm/stm32/stm32f4discovery/scripts/Make.defs index 4efc15e7578..013f8ce02e2 100644 --- a/boards/arm/stm32/stm32f4discovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/scripts/Make.defs @@ -34,11 +34,10 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing endif -ARCHCFLAGS = -fno-common -fno-builtin -ifeq ($(CONFIG_CXX_EXCEPTION),y) - ARCHCXXFLAGS = -fno-common -fno-builtin -else - ARCHCXXFLAGS = -fno-common -fno-builtin -fno-exceptions -fcheck-new +ARCHCFLAGS = -fno-common -fno-builtin -ffunction-sections -fdata-sections +ARCHCXXFLAGS = -fno-common -fno-builtin -ffunction-sections -fdata-sections +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS = -fno-exceptions -fcheck-new endif ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef @@ -65,6 +64,8 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 +LDFLAGS += --gc-sections + # Loadable module definitions CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs