@@ -104,7 +104,25 @@ SECTIONS
104
104
. += M_CRASH_DATA_RAM_SIZE;
105
105
. = ALIGN (8);
106
106
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
107
- } > SRAM1
107
+ } > SRAM2
108
+
109
+ /* .stack section doesn't contains any symbols. It is only
110
+ * used for linker to reserve space for the isr stack section
111
+ * WARNING : .stack should come immediately after the last secure memory
112
+ * section. This provides stack overflow detection. */
113
+ .stack (NOLOAD) :
114
+ {
115
+ __StackLimit = .;
116
+ *(.stack*);
117
+ . += STACK_SIZE - (. - __StackLimit);
118
+ } > SRAM2
119
+
120
+ /* Set stack top to end of RAM, and stack limit move down by
121
+ * size of stack_dummy section */
122
+ __StackTop = ADDR (.stack) + SIZEOF (.stack);
123
+ _estack = __StackTop;
124
+ __StackLimit = ADDR (.stack);
125
+ PROVIDE (__stack = __StackTop);
108
126
109
127
.data : AT (__etext)
110
128
{
@@ -126,7 +144,6 @@ SECTIONS
126
144
KEEP(*(.init_array))
127
145
PROVIDE_HIDDEN (__init_array_end = .);
128
146
129
-
130
147
. = ALIGN (8);
131
148
/* finit data */
132
149
PROVIDE_HIDDEN (__fini_array_start = .);
@@ -139,9 +156,11 @@ SECTIONS
139
156
/* All data end */
140
157
__data_end__ = .;
141
158
_edata = .;
142
-
143
159
} > SRAM1
144
160
161
+ /* Check if bss exceeds SRAM1 */
162
+ ASSERT (__data_end__ <= (ORIGIN (SRAM1)+LENGTH (SRAM1)), ".data is too big for SRAM1")
163
+
145
164
.bss :
146
165
{
147
166
. = ALIGN (8);
@@ -152,41 +171,22 @@ SECTIONS
152
171
. = ALIGN (8);
153
172
__bss_end__ = .;
154
173
_ebss = .;
155
- } > SRAM2
174
+ } > SRAM1
175
+
176
+ /* Check if bss exceeds SRAM1 */
177
+ ASSERT (__bss_end__ <= (ORIGIN (SRAM1)+LENGTH (SRAM1)), "BSS is too big for SRAM1")
156
178
157
179
.heap (COPY) :
158
180
{
159
181
__end__ = .;
182
+ __mbed_sbrk_start_0 = .;
160
183
end = __end__;
161
184
*(.heap*)
162
- . += (ORIGIN (SRAM1) + LENGTH (SRAM1) - .);
163
- __HeapLimit = .;
164
- } > SRAM1
165
- PROVIDE (__heap_size = SIZEOF (.heap));
166
- PROVIDE (__mbed_sbrk_start = ADDR (.heap));
167
- PROVIDE (__mbed_krbs_start = ADDR (.heap) + SIZEOF (.heap));
168
- /* Check if data + heap exceeds RAM1 limit */
169
- ASSERT ((ORIGIN (SRAM1)+LENGTH (SRAM1)) >= __HeapLimit, "SRAM1 overflow")
170
- /* .stack_dummy section doesn't contains any symbols. It is only
171
- * used for linker to calculate size of stack sections, and assign
172
- * values to stack symbols later */
173
- .stack_dummy (COPY) :
174
- {
175
- *(.stack*)
176
- . += (ORIGIN (SRAM2) + STACK_SIZE - .);
177
- __mbed_sbrk_start_0 = .;
178
- . += (ORIGIN (SRAM2) + LENGTH (SRAM2) - .);
185
+ . = (ORIGIN (SRAM2) + LENGTH (SRAM2));
179
186
__mbed_krbs_start_0 = .;
187
+ __mbed_sbrk_start = __bss_end__;
188
+ . = (ORIGIN (SRAM1) + LENGTH (SRAM1));
189
+ __mbed_krbs_start = .;
190
+ __HeapLimit = .;
180
191
} > SRAM2
181
-
182
- /* Set stack top to end of RAM, and stack limit move down by
183
- * size of stack_dummy section */
184
- __StackTop = ORIGIN (SRAM2) + LENGTH (SRAM2);
185
- _estack = __StackTop;
186
- __StackLimit = __StackTop - STACK_SIZE;
187
- PROVIDE (__stack = __StackTop);
188
- /* Check if stack exceeds RAM2 limit */
189
- ASSERT ((ORIGIN (SRAM2)+LENGTH (SRAM2)) >= __StackLimit, "SRAM2 overflow")
190
- /* Check if bss exceeds __StackLimit */
191
- ASSERT (__bss_end__ <= __StackLimit, "BSS is too big for RAM2")
192
192
}
0 commit comments