diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index ca22e093c3..4d0ca70b86 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -74,14 +74,13 @@ CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES)) CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD) CFLAGS += -fno-strict-aliasing CFLAGS += -fstack-usage -CFLAGS += -fdata-sections -ffunction-sections CFLAGS += -Iboards/$(BOARD) CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>' +CFLAGS += -flto LDFLAGS = $(CFLAGS) LDFLAGS += -Xlinker -Map=$(@:.elf=.map) LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/ -LDFLAGS += -Wl,--gc-sections #Debugging/Optimization ifeq ($(DEBUG), 1) diff --git a/ports/nrf/device/nrf51/startup_nrf51822.c b/ports/nrf/device/nrf51/startup_nrf51822.c index add8218e6c..2f15f0f49c 100644 --- a/ports/nrf/device/nrf51/startup_nrf51822.c +++ b/ports/nrf/device/nrf51/startup_nrf51822.c @@ -103,7 +103,7 @@ void SWI3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler" void SWI4_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void SWI5_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); -const func __Vectors[] __attribute__ ((section(".isr_vector"))) = { +const func __Vectors[] __attribute__ ((section(".isr_vector"),used)) = { (func)&_estack, Reset_Handler, NMI_Handler, diff --git a/ports/nrf/device/nrf52/startup_nrf52832.c b/ports/nrf/device/nrf52/startup_nrf52832.c index b36ac0d971..6eafcc220b 100644 --- a/ports/nrf/device/nrf52/startup_nrf52832.c +++ b/ports/nrf/device/nrf52/startup_nrf52832.c @@ -107,7 +107,7 @@ void SPIM2_SPIS2_SPI2_IRQHandler (void) __attribute__ ((weak, alias("Default_Han void RTC2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void I2S_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); -const func __Vectors[] __attribute__ ((section(".isr_vector"))) = { +const func __Vectors[] __attribute__ ((section(".isr_vector"),used)) = { (func)&_estack, Reset_Handler, NMI_Handler, diff --git a/ports/nrf/device/nrf52/startup_nrf52840.c b/ports/nrf/device/nrf52/startup_nrf52840.c index 998696c08e..0935d7d1d0 100644 --- a/ports/nrf/device/nrf52/startup_nrf52840.c +++ b/ports/nrf/device/nrf52/startup_nrf52840.c @@ -114,7 +114,7 @@ void CRYPTOCELL_IRQHandler (void) __attribute__ ((weak, alias("Default_Han void SPIM3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void PWM3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); -const func __Vectors[] __attribute__ ((section(".isr_vector"))) = { +const func __Vectors[] __attribute__ ((section(".isr_vector"),used)) = { (func)&_estack, Reset_Handler, NMI_Handler,