-
Notifications
You must be signed in to change notification settings - Fork 339
/
linker_ld.cmake
158 lines (154 loc) · 3.34 KB
/
linker_ld.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
if((NOT CCRAM_SIZE) OR (CCRAM_SIZE STREQUAL "0K"))
set(CCRAM_DEFINITION "")
set(CCRAM_SECTION "")
else()
set(CCRAM_DEFINITION " CCMRAM (rw) : ORIGIN = ${CCRAM_ORIGIN}, LENGTH = ${CCRAM_SIZE}\n")
set(CCRAM_SECTION "
_siccmram = LOADADDR(.ccmram);\n\
.ccmram :\n\
{\n\
. = ALIGN(4);\n\
_sccmram = .;\n\
*(.ccmram)\n\
*(.ccmram*)\n\
. = ALIGN(4);\n\
_eccmram = .;\n\
} >CCMRAM AT> FLASH\n\
")
endif()
if((NOT RAM_SHARE_SIZE) OR (RAM_SHARE_SIZE STREQUAL "0K"))
set(RAM_SHARE_DEFINITION "")
set(RAM_SHARE_SECTION "")
else()
set(RAM_SHARE_DEFINITION " RAM_SHARED (rw) : ORIGIN = ${RAM_SHARE_ORIGIN}, LENGTH = ${RAM_SHARE_SIZE}\n")
set(RAM_SHARE_SECTION "
MAPPING_TABLE (NOLOAD) : { *(MAPPING_TABLE) } >RAM_SHARED\n\
MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED\n\
MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED\n\
")
endif()
set(SCRIPT_TEXT
"ENTRY(Reset_Handler)\n\
\n\
_estack = ${RAM_ORIGIN} + ${RAM_SIZE};\n\
_Min_Heap_Size = ${HEAP_SIZE};\n\
_Min_Stack_Size = ${STACK_SIZE};\n\
\n\
MEMORY\n\
{\n\
FLASH (rx) : ORIGIN = ${FLASH_ORIGIN}, LENGTH = ${FLASH_SIZE}\n\
RAM (xrw) : ORIGIN = ${RAM_ORIGIN}, LENGTH = ${RAM_SIZE}\n\
${CCRAM_DEFINITION}\n\
${RAM_SHARE_DEFINITION}\n\
}\n\
\n\
SECTIONS\n\
{\n\
.isr_vector :\n\
{\n\
. = ALIGN(4);\n\
KEEP(*(.isr_vector))\n\
. = ALIGN(4);\n\
} >FLASH\n\
\n\
.text :\n\
{\n\
. = ALIGN(4);\n\
*(.text)\n\
*(.text*)\n\
*(.glue_7)\n\
*(.glue_7t)\n\
*(.eh_frame)\n\
\n\
KEEP (*(.init))\n\
KEEP (*(.fini))\n\
\n\
. = ALIGN(4);\n\
_etext = .;\n\
} >FLASH\n\
\n\
.rodata :\n\
{\n\
. = ALIGN(4);\n\
*(.rodata)\n\
*(.rodata*)\n\
. = ALIGN(4);\n\
} >FLASH\n\
\n\
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH\n\
.ARM : {\n\
__exidx_start = .;\n\
*(.ARM.exidx*)\n\
__exidx_end = .;\n\
} >FLASH\n\
\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\
\n\
_sidata = LOADADDR(.data);\n\
\n\
.data : \n\
{\n\
. = ALIGN(4);\n\
_sdata = .; \n\
*(.data)\n\
*(.data*)\n\
\n\
. = ALIGN(4);\n\
_edata = .;\n\
} >RAM AT> FLASH\n\
${CCRAM_SECTION}\n\
. = ALIGN(4);\n\
.bss :\n\
{\n\
_sbss = .;\n\
__bss_start__ = _sbss;\n\
*(.bss)\n\
*(.bss*)\n\
*(COMMON)\n\
\n\
. = ALIGN(4);\n\
_ebss = .;\n\
__bss_end__ = _ebss;\n\
} >RAM\n\
\n\
._user_heap_stack :\n\
{\n\
. = ALIGN(8);\n\
PROVIDE ( end = . );\n\
PROVIDE ( _end = . );\n\
. = . + _Min_Heap_Size;\n\
. = . + _Min_Stack_Size;\n\
. = ALIGN(8);\n\
} >RAM\n\
\n\
/DISCARD/ :\n\
{\n\
libc.a ( * )\n\
libm.a ( * )\n\
libgcc.a ( * )\n\
}\n\
\n\
.ARM.attributes 0 : { *(.ARM.attributes) }\n\
${RAM_SHARE_SECTION}\n\
}"
)
file(WRITE "${LINKER_SCRIPT}" "${SCRIPT_TEXT}")