@@ -100,65 +100,88 @@ SECTIONS
100
100
101
101
.text _stext :
102
102
{
103
+ __stext = .;
104
+
103
105
/* Put reset handler first in .text section so it ends up as the entry */
104
106
/* point of the program. */
105
107
KEEP(*(.init));
106
- KEEP(*(.init.rust));
107
108
. = ALIGN(4);
108
109
KEEP(*(.init.trap));
109
110
. = ALIGN(4);
110
111
*(.trap);
111
112
*(.trap.rust);
112
113
*(.text.abort);
113
114
*(.text .text.*);
115
+
116
+ . = ALIGN(4);
117
+ __etext = .;
114
118
} > REGION_TEXT
115
119
116
120
.rodata : ALIGN(4)
117
121
{
122
+ . = ALIGN(4);
123
+ __srodata = .;
124
+
118
125
*(.srodata .srodata.*);
119
126
*(.rodata .rodata.*);
120
127
121
- /* 4 -byte align the end (VMA) of this section.
128
+ /* ${ARCH_WIDTH} -byte align the end (VMA) of this section.
122
129
This is required by LLD to ensure the LMA of the following .data
123
130
section will have the correct alignment. */
124
- . = ALIGN(4);
131
+ . = ALIGN(${ARCH_WIDTH});
132
+ __erodata = .;
125
133
} > REGION_RODATA
126
134
127
135
.data : ALIGN(${ARCH_WIDTH})
128
136
{
129
- _sidata = LOADADDR(.data);
130
- _sdata = .;
137
+ . = ALIGN(${ARCH_WIDTH});
138
+ __sdata = .;
139
+
131
140
/* Must be called __global_pointer$ for linker relaxations to work. */
132
141
PROVIDE(__global_pointer$ = . + 0x800);
133
142
*(.sdata .sdata.* .sdata2 .sdata2.*);
134
143
*(.data .data.*);
135
- . = ALIGN(${ARCH_WIDTH});
136
- _edata = .;
144
+
137
145
} > REGION_DATA AT > REGION_RODATA
146
+
147
+ /* Allow sections from user `memory.x` injected using `INSERT AFTER .data` to
148
+ * use the .data loading mechanism by pushing __edata. Note: do not change
149
+ * output region or load region in those user sections! */
150
+ . = ALIGN(${ARCH_WIDTH});
151
+ __edata = .;
152
+
153
+ /* LMA of .data */
154
+ __sidata = LOADADDR(.data);
138
155
139
156
.bss (NOLOAD) : ALIGN(${ARCH_WIDTH})
140
157
{
141
- _sbss = .;
142
- *(.sbss .sbss.* .bss .bss.*);
143
158
. = ALIGN(${ARCH_WIDTH});
144
- _ebss = .;
159
+ __sbss = .;
160
+
161
+ *(.sbss .sbss.* .bss .bss.*);
145
162
} > REGION_BSS
146
163
164
+ /* Allow sections from user `memory.x` injected using `INSERT AFTER .bss` to
165
+ * use the .bss zeroing mechanism by pushing __ebss. Note: do not change
166
+ * output region or load region in those user sections! */
167
+ . = ALIGN(${ARCH_WIDTH});
168
+ __ebss = .;
169
+
147
170
/* fictitious region that represents the memory available for the heap */
148
171
.heap (NOLOAD) :
149
172
{
150
- _sheap = .;
173
+ __sheap = .;
151
174
. += _heap_size;
152
175
. = ALIGN(4);
153
- _eheap = .;
176
+ __eheap = .;
154
177
} > REGION_HEAP
155
178
156
179
/* fictitious region that represents the memory available for the stack */
157
180
.stack (NOLOAD) :
158
181
{
159
- _estack = .;
182
+ __estack = .;
160
183
. = ABSOLUTE(_stack_start);
161
- _sstack = .;
184
+ __sstack = .;
162
185
} > REGION_STACK
163
186
164
187
/* fake output .got section */
@@ -190,16 +213,16 @@ ERROR(riscv-rt): the start of the REGION_STACK must be 4-byte aligned");
190
213
ASSERT(_stext % 4 == 0, "
191
214
ERROR(riscv-rt): `_stext` must be 4-byte aligned");
192
215
193
- ASSERT(_sdata % ${ARCH_WIDTH} == 0 && _edata % ${ARCH_WIDTH} == 0, "
216
+ ASSERT(__sdata % ${ARCH_WIDTH} == 0 && __edata % ${ARCH_WIDTH} == 0, "
194
217
BUG(riscv-rt): .data is not ${ARCH_WIDTH}-byte aligned");
195
218
196
- ASSERT(_sidata % ${ARCH_WIDTH} == 0, "
219
+ ASSERT(__sidata % ${ARCH_WIDTH} == 0, "
197
220
BUG(riscv-rt): the LMA of .data is not ${ARCH_WIDTH}-byte aligned");
198
221
199
- ASSERT(_sbss % ${ARCH_WIDTH} == 0 && _ebss % ${ARCH_WIDTH} == 0, "
222
+ ASSERT(__sbss % ${ARCH_WIDTH} == 0 && __ebss % ${ARCH_WIDTH} == 0, "
200
223
BUG(riscv-rt): .bss is not ${ARCH_WIDTH}-byte aligned");
201
224
202
- ASSERT(_sheap % 4 == 0, "
225
+ ASSERT(__sheap % 4 == 0, "
203
226
BUG(riscv-rt): start of .heap is not 4-byte aligned");
204
227
205
228
ASSERT(_stext + SIZEOF(.text) < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "
0 commit comments