aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/stm32.ld13
-rw-r--r--cmake/stm32.toolchain.cmake8
2 files changed, 15 insertions, 6 deletions
diff --git a/cmake/stm32.ld b/cmake/stm32.ld
index fc69574..bafd520 100644
--- a/cmake/stm32.ld
+++ b/cmake/stm32.ld
@@ -16,7 +16,7 @@ SECTIONS
{
/* The first word has to be the initial stack pointer */
LONG(__initial_stack_pointer);
- */init_high.cpp.obj(.isr_vectors)
+ KEEP(*/init_high.cpp.obj(.isr_vectors))
} >FLASH
ASSERT(SIZEOF(.isr) > 100, "The isr_vectors section is too small")
ASSERT(SIZEOF(.isr) < 1000, "The isr_vectors section is too big")
@@ -29,11 +29,20 @@ SECTIONS
*(.rodata*)
} >FLASH
+ .init_arrays :
+ {
+ _init_array_start = .;
+ KEEP(*(.init_array))
+ KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
+ _init_array_end = .;
+ } >FLASH
+
. = ORIGIN(RAM);
.data ALIGN(4) :
{
- *(.data*)
+ *(.data)
+ *(.data.*)
} >RAM AT >FLASH
.bss ALIGN(4) (NOLOAD) :
diff --git a/cmake/stm32.toolchain.cmake b/cmake/stm32.toolchain.cmake
index ab73d90..e595ec9 100644
--- a/cmake/stm32.toolchain.cmake
+++ b/cmake/stm32.toolchain.cmake
@@ -22,13 +22,13 @@ set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
set(TARGET_FLAGS "-mcpu=cortex-m3 -mthumb")
-set(BASE_FLAGS "-Wall -g -ffunction-sections -fdata-sections ${TARGET_FLAGS}")
+set(BASE_FLAGS "-O3 -ffreestanding -nostdlib -Wall -Wextra -g -ffunction-sections -fdata-sections ${TARGET_FLAGS}")
-set(CMAKE_C_FLAGS "${BASE_FLAGS}" CACHE STRING "c flags") # XXX Generate TIME_T dynamically.
+set(CMAKE_C_FLAGS "${BASE_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${BASE_FLAGS} -fno-exceptions -fno-rtti -felide-constructors -std=c++14" CACHE STRING "c++ flags")
-set(LINKER_FLAGS "-O3 ${TARGET_FLAGS}")
-set(LINKER_LIBS "-larm_cortexM4l_math -lm")
+set(LINKER_FLAGS "-O3 -Wl,--gc-sections ${TARGET_FLAGS}")
+#set(LINKER_LIBS "-larm_cortexM4l_math -lm")
set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" FORCE)