From 66298f5cb62058bc0fb6608b2c6e9cd35b92b38d Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 16 Sep 2016 11:42:49 +0200 Subject: [PATCH] [ion] Enable building with --gc-sections Change-Id: Ibddb03d5fc95f99954583a51c02257dfcba3a326 --- Makefile | 3 +- ion/src/device/boot/flash.ld | 37 ++------------------- ion/src/device/boot/isr.c | 63 +++++++++++++++++------------------- ion/src/device/boot/isr.h | 28 ---------------- ion/src/device/boot/rt0.cpp | 10 +++--- ion/src/device/boot/rt0.h | 7 ++++ 6 files changed, 44 insertions(+), 104 deletions(-) delete mode 100644 ion/src/device/boot/isr.h create mode 100644 ion/src/device/boot/rt0.h diff --git a/Makefile b/Makefile index 29a481311..d85a570b3 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,7 @@ ifeq ($(DEBUG),1) SFLAGS += -ggdb3 -DDEBUG=1 -O0 else SFLAGS += -Os -fdata-sections -ffunction-sections -#LDFLAGS += --gc-sections -#FIXME: --gc-sections doesn't seem to be working +LDFLAGS += --gc-sections endif # Language-specific flags diff --git a/ion/src/device/boot/flash.ld b/ion/src/device/boot/flash.ld index f927fd046..96c14e717 100644 --- a/ion/src/device/boot/flash.ld +++ b/ion/src/device/boot/flash.ld @@ -29,42 +29,9 @@ SECTIONS { * * We're generating the ISR vector table in code because it's very * convenient: using function pointers, we can easily point to the service - * routine for each interrupt. - * - * Last but not least, instead of pointing directly to handler functions in - * the ISR declaration, we take the opportunity of having a custom linker - * script to use meaningful names in the ISR declaration. */ + * routine for each interrupt. */ - PROVIDE(_ResetServiceRoutine = _start); - PROVIDE(_NMIServiceRoutine = 0); - PROVIDE(_HardFaultServiceRoutine = abort); - PROVIDE(_MemManageServiceRoutine = 0); - PROVIDE(_BusFaultServiceRoutine = 0); - PROVIDE(_UsageFaultServiceRoutine = 0); - PROVIDE(_SVCallServiceRoutine = 0); - PROVIDE(_DebugMonitorServiceRoutine = 0); - PROVIDE(_PendSVServiceRoutine = 0); - PROVIDE(_SysTickServiceRoutine = 0); - PROVIDE(_WWDGServiceRoutine = 0); - PROVIDE(_PVDServiceRoutine = 0); - PROVIDE(_TampStampServiceRoutine = 0); - PROVIDE(_RtcWakeupServiceRoutine = 0); - PROVIDE(_FlashServiceRoutine = 0); - PROVIDE(_RCCServiceRoutine = 0); - PROVIDE(_EXTI0ServiceRoutine = 0); - PROVIDE(_EXTI1ServiceRoutine = 0); - PROVIDE(_EXTI2ServiceRoutine = 0); - PROVIDE(_EXTI3ServiceRoutine = 0); - PROVIDE(_EXTI4ServiceRoutine = 0); - PROVIDE(_DMA1Stream0ServiceRoutine = 0); - PROVIDE(_DMA1Stream1ServiceRoutine = 0); - PROVIDE(_DMA1Stream2ServiceRoutine = 0); - PROVIDE(_DMA1Stream3ServiceRoutine = 0); - PROVIDE(_DMA1Stream4ServiceRoutine = 0); - PROVIDE(_DMA1Stream5ServiceRoutine = 0); - PROVIDE(_DMA1Stream6ServiceRoutine = 0); - - *(.isr_vector_table) + KEEP(*(.isr_vector_table)) } >FLASH .text : { diff --git a/ion/src/device/boot/isr.c b/ion/src/device/boot/isr.c index b4391df4a..53495ed27 100644 --- a/ion/src/device/boot/isr.c +++ b/ion/src/device/boot/isr.c @@ -1,5 +1,4 @@ -#include "isr.h" - +#include "rt0.h" extern const void * _stack_start; /* Interrupt Service Routines are void->void functions */ @@ -13,40 +12,38 @@ typedef void(*ISR)(void); #define INITIALISATION_VECTOR_SIZE 0x6B -void _start(); - ISR InitialisationVector[INITIALISATION_VECTOR_SIZE] __attribute__((section(".isr_vector_table"))) = { - (ISR)&_stack_start, - _ResetServiceRoutine, - _NMIServiceRoutine, - _HardFaultServiceRoutine, - _MemManageServiceRoutine, - _BusFaultServiceRoutine, - _UsageFaultServiceRoutine, + (ISR)&_stack_start, // Stack start + start, // Reset service routine, + 0, // NMI service routine, + abort, // HardFault service routine, + 0, // MemManage service routine, + 0, // BusFault service routine, + 0, // UsageFault service routine, 0, 0, 0, 0, // Reserved - _SVCallServiceRoutine, - _DebugMonitorServiceRoutine, + 0, // SVCall service routine, + 0, // DebugMonitor service routine, 0, // Reserved - _PendSVServiceRoutine, - _SysTickServiceRoutine, - _WWDGServiceRoutine, - _PVDServiceRoutine, - _TampStampServiceRoutine, - _RtcWakeupServiceRoutine, - _FlashServiceRoutine, - _RCCServiceRoutine, - _EXTI0ServiceRoutine, - _EXTI1ServiceRoutine, - _EXTI2ServiceRoutine, - _EXTI3ServiceRoutine, - _EXTI4ServiceRoutine, - _DMA1Stream0ServiceRoutine, - _DMA1Stream1ServiceRoutine, - _DMA1Stream2ServiceRoutine, - _DMA1Stream3ServiceRoutine, - _DMA1Stream4ServiceRoutine, - _DMA1Stream5ServiceRoutine, - _DMA1Stream6ServiceRoutine + 0, // PendSV service routine, + 0, // SysTick service routine + 0, // WWDG service routine + 0, // PVD service routine + 0, // TampStamp service routine + 0, // RtcWakeup service routine + 0, // Flash service routine + 0, // RCC service routine + 0, // EXTI0 service routine + 0, // EXTI1 service routine + 0, // EXTI2 service routine + 0, // EXTI3 service routine + 0, // EXTI4 service routine + 0, // DMA1Stream0 service routine + 0, // DMA1Stream1 service routine + 0, // DMA1Stream2 service routine + 0, // DMA1Stream3 service routine + 0, // DMA1Stream4 service routine + 0, // DMA1Stream5 service routine + 0 // DMA1Stream6 service routine }; diff --git a/ion/src/device/boot/isr.h b/ion/src/device/boot/isr.h deleted file mode 100644 index 185805362..000000000 --- a/ion/src/device/boot/isr.h +++ /dev/null @@ -1,28 +0,0 @@ -void _ResetServiceRoutine(); -void _NMIServiceRoutine(); -void _HardFaultServiceRoutine(); -void _MemManageServiceRoutine(); -void _BusFaultServiceRoutine(); -void _UsageFaultServiceRoutine(); -void _SVCallServiceRoutine(); -void _DebugMonitorServiceRoutine(); -void _PendSVServiceRoutine(); -void _SysTickServiceRoutine(); -void _WWDGServiceRoutine(); -void _PVDServiceRoutine(); -void _TampStampServiceRoutine(); -void _RtcWakeupServiceRoutine(); -void _FlashServiceRoutine(); -void _RCCServiceRoutine(); -void _EXTI0ServiceRoutine(); -void _EXTI1ServiceRoutine(); -void _EXTI2ServiceRoutine(); -void _EXTI3ServiceRoutine(); -void _EXTI4ServiceRoutine(); -void _DMA1Stream0ServiceRoutine(); -void _DMA1Stream1ServiceRoutine(); -void _DMA1Stream2ServiceRoutine(); -void _DMA1Stream3ServiceRoutine(); -void _DMA1Stream4ServiceRoutine(); -void _DMA1Stream5ServiceRoutine(); -void _DMA1Stream6ServiceRoutine(); diff --git a/ion/src/device/boot/rt0.cpp b/ion/src/device/boot/rt0.cpp index 38de5a534..5aaade29b 100644 --- a/ion/src/device/boot/rt0.cpp +++ b/ion/src/device/boot/rt0.cpp @@ -1,3 +1,6 @@ +extern "C" { +#include "rt0.h" +} #include #include #include @@ -9,11 +12,6 @@ extern char _data_section_end_ram; extern char _bss_section_start_ram; extern char _bss_section_end_ram; -extern "C" { - void _start(); - void abort(); -} - void abort() { #ifdef DEBUG while (1) { @@ -23,7 +21,7 @@ void abort() { #endif } -void _start() { +void start() { // This is where execution starts after reset. // Many things are not initialized yet so the code here has to pay attention. diff --git a/ion/src/device/boot/rt0.h b/ion/src/device/boot/rt0.h new file mode 100644 index 000000000..65b2365a4 --- /dev/null +++ b/ion/src/device/boot/rt0.h @@ -0,0 +1,7 @@ +#ifndef ION_DEVICE_BOOT_RT0_H +#define ION_DEVICE_BOOT_RT0_H + +void start(); +void abort(); + +#endif