@@ -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 */
@@ -169,9 +192,6 @@ SECTIONS
169
192
{
170
193
KEEP(*(.got .got.*));
171
194
}
172
-
173
- .eh_frame (INFO) : { KEEP(*(.eh_frame)) }
174
- .eh_frame_hdr (INFO) : { *(.eh_frame_hdr) }
175
195
}
176
196
177
197
/* Do not exceed this mark in the error messages above | */
@@ -187,25 +207,22 @@ ERROR(riscv-rt): the start of the REGION_DATA must be ${ARCH_WIDTH}-byte aligned
187
207
ASSERT(ORIGIN(REGION_HEAP) % 4 == 0, "
188
208
ERROR(riscv-rt): the start of the REGION_HEAP must be 4-byte aligned");
189
209
190
- ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
191
- ERROR(riscv-rt): the start of the REGION_TEXT must be 4-byte aligned");
192
-
193
210
ASSERT(ORIGIN(REGION_STACK) % 4 == 0, "
194
211
ERROR(riscv-rt): the start of the REGION_STACK must be 4-byte aligned");
195
212
196
213
ASSERT(_stext % 4 == 0, "
197
214
ERROR(riscv-rt): `_stext` must be 4-byte aligned");
198
215
199
- ASSERT(_sdata % ${ARCH_WIDTH} == 0 && _edata % ${ARCH_WIDTH} == 0, "
216
+ ASSERT(__sdata % ${ARCH_WIDTH} == 0 && __edata % ${ARCH_WIDTH} == 0, "
200
217
BUG(riscv-rt): .data is not ${ARCH_WIDTH}-byte aligned");
201
218
202
- ASSERT(_sidata % ${ARCH_WIDTH} == 0, "
219
+ ASSERT(__sidata % ${ARCH_WIDTH} == 0, "
203
220
BUG(riscv-rt): the LMA of .data is not ${ARCH_WIDTH}-byte aligned");
204
221
205
- ASSERT(_sbss % ${ARCH_WIDTH} == 0 && _ebss % ${ARCH_WIDTH} == 0, "
222
+ ASSERT(__sbss % ${ARCH_WIDTH} == 0 && __ebss % ${ARCH_WIDTH} == 0, "
206
223
BUG(riscv-rt): .bss is not ${ARCH_WIDTH}-byte aligned");
207
224
208
- ASSERT(_sheap % 4 == 0, "
225
+ ASSERT(__sheap % 4 == 0, "
209
226
BUG(riscv-rt): start of .heap is not 4-byte aligned");
210
227
211
228
ASSERT(_stext + SIZEOF(.text) < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "
@@ -216,11 +233,11 @@ ASSERT(SIZEOF(.stack) > (_max_hart_id + 1) * _hart_stack_size, "
216
233
ERROR(riscv-rt): .stack section is too small for allocating stacks for all the harts.
217
234
Consider changing `_max_hart_id` or `_hart_stack_size`.");
218
235
236
+ /* # Other checks */
219
237
ASSERT(SIZEOF(.got) == 0, "
220
- .got section detected in the input files. Dynamic relocations are not
221
- supported. If you are linking to C code compiled using the `gcc` crate
222
- then modify your build script to compile the C code _without_ the
223
- -fPIC flag. See the documentation of the `gcc::Config.fpic` method for
224
- details.");
238
+ ERROR(riscv-rt): .got section detected in the input files. Dynamic relocations are not
239
+ supported. If you are linking to C code compiled using the `cc` crate then modify your
240
+ build script to compile the C code _without_ the -fPIC flag. See the documentation of
241
+ the `cc::Build.pic` method for details.");
225
242
226
243
/* Do not exceed this mark in the error messages above | */
0 commit comments