-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm32_linker.cmake
127 lines (125 loc) · 3.19 KB
/
stm32_linker.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# TODO: Add support for external RAM
IF(STM32_FAMILY STREQUAL "F4")
SET(STM32_CCRAM_DEF " CCMRAM (rw) : ORIGIN = ${STM32_CCRAM_ORIGIN}, LENGTH = ${STM32_CCRAM_SIZE}\n")
SET(STM32_CCRAM_SECTION
" _siccmram = LOADADDR(.ccmram)\;\n"
" .ccmram :\n"
" {"
" . = ALIGN(4)\;\n"
" _sccmram = .\;\n"
" *(.ccmram)\n"
" *(.ccmram*)\n"
" . = ALIGN(4)\;\n"
" _eccmram = .\;\n"
" } >CCMRAM AT> FLASH\n"
)
ELSE()
SET(STM32_CCRAM_DEF "")
SET(STM32_CCRAM_SECTION "")
ENDIF()
SET(STM32_LINKER_SCRIPT_TEXT
"ENTRY(Reset_Handler)\n"
"_estack = ${STM32_RAM_ORIGIN} + ${STM32_RAM_SIZE} - 1\;\n"
"_Min_Heap_Size = ${STM32_MIN_HEAP_SIZE}\;\n"
"_Min_Stack_Size = ${STM32_MIN_STACK_SIZE}\;\n"
"MEMORY\n"
"{\n"
" FLASH (rx) : ORIGIN = ${STM32_FLASH_ORIGIN}, LENGTH = ${STM32_FLASH_SIZE}\n"
" RAM (xrw) : ORIGIN = ${STM32_RAM_ORIGIN}, LENGTH = ${STM32_RAM_SIZE}\n"
"${STM32_CCRAM_DEF}"
"}\n"
"SECTIONS\n"
"{\n"
" .isr_vector :\n"
" {\n"
" . = ALIGN(4)\;\n"
" KEEP(*(.isr_vector))\n"
" . = ALIGN(4)\;\n"
" } >FLASH\n"
" .text :\n"
" {\n"
" . = ALIGN(4)\;\n"
" *(.text)\n"
" *(.text*)\n"
" *(.glue_7)\n"
" *(.glue_7t)\n"
" *(.eh_frame)\n"
" KEEP (*(.init))\n"
" KEEP (*(.fini))\n"
" . = ALIGN(4)\;\n"
" _etext = .\;\n"
" } >FLASH\n"
" .rodata :\n"
" {\n"
" . = ALIGN(4)\;\n"
" *(.rodata)\n"
" *(.rodata*)\n"
" . = ALIGN(4)\;\n"
" } >FLASH\n"
" .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH\n"
" .ARM : {\n"
" __exidx_start = .\;\n"
" *(.ARM.exidx*)\n"
" __exidx_end = .\;\n"
" } >FLASH\n"
" .preinit_array :\n"
" {\n"
" PROVIDE_HIDDEN (__preinit_array_start = .)\;\n"
" KEEP (*(.preinit_array*))\n"
" PROVIDE_HIDDEN (__preinit_array_end = .)\;\n"
" } >FLASH\n"
" .init_array :\n"
" {\n"
" PROVIDE_HIDDEN (__init_array_start = .)\;\n"
" KEEP (*(SORT(.init_array.*)))\n"
" KEEP (*(.init_array*))\n"
" PROVIDE_HIDDEN (__init_array_end = .)\;\n"
" } >FLASH\n"
" .fini_array :\n"
" {\n"
" PROVIDE_HIDDEN (__fini_array_start = .)\;\n"
" KEEP (*(SORT(.fini_array.*)))\n"
" KEEP (*(.fini_array*))\n"
" PROVIDE_HIDDEN (__fini_array_end = .)\;\n"
" } >FLASH\n"
" _sidata = LOADADDR(.data)\;\n"
" .data : \n"
" {\n"
" . = ALIGN(4)\;\n"
" _sdata = .\;\n"
" *(.data)\n"
" *(.data*)\n"
" . = ALIGN(4)\;\n"
" _edata = .\;\n"
" } >RAM AT> FLASH\n"
"${STM32_CCRAM_SECTION}"
" . = ALIGN(4)\;\n"
" .bss :\n"
" {\n"
" _sbss = .\;\n"
" __bss_start__ = _sbss\;\n"
" *(.bss)\n"
" *(.bss*)\n"
" *(COMMON)\n"
" . = ALIGN(4)\;\n"
" _ebss = .\;\n"
" __bss_end__ = _ebss\;\n"
" } >RAM\n"
" ._user_heap_stack :\n"
" {\n"
" . = ALIGN(4)\;\n"
" PROVIDE ( end = . )\;\n"
" PROVIDE ( _end = . )\;\n"
" . = . + _Min_Heap_Size\;\n"
" . = . + _Min_Stack_Size\;\n"
" . = ALIGN(4)\;\n"
" } >RAM\n"
" /DISCARD/ :\n"
" {\n"
" libc.a ( * )\n"
" libm.a ( * )\n"
" libgcc.a ( * )\n"
" }\n"
" .ARM.attributes 0 : { *(.ARM.attributes) }\n"
"}\n"
)