@@ -100,65 +100,88 @@ SECTIONS
100100
101101 .text _stext :
102102 {
103+ __stext = .;
104+
103105 /* Put reset handler first in .text section so it ends up as the entry */
104106 /* point of the program. */
105107 KEEP(*(.init));
106- KEEP(*(.init.rust));
107108 . = ALIGN(4);
108109 KEEP(*(.init.trap));
109110 . = ALIGN(4);
110111 *(.trap);
111112 *(.trap.rust);
112113 *(.text.abort);
113114 *(.text .text.*);
115+
116+ . = ALIGN(4);
117+ __etext = .;
114118 } > REGION_TEXT
115119
116120 .rodata : ALIGN(4)
117121 {
122+ . = ALIGN(4);
123+ __srodata = .;
124+
118125 *(.srodata .srodata.*);
119126 *(.rodata .rodata.*);
120127
121- /* 4 -byte align the end (VMA) of this section.
128+ /* ${ARCH_WIDTH} -byte align the end (VMA) of this section.
122129 This is required by LLD to ensure the LMA of the following .data
123130 section will have the correct alignment. */
124- . = ALIGN(4);
131+ . = ALIGN(${ARCH_WIDTH});
132+ __erodata = .;
125133 } > REGION_RODATA
126134
127135 .data : ALIGN(${ARCH_WIDTH})
128136 {
129- _sidata = LOADADDR(.data);
130- _sdata = .;
137+ . = ALIGN(${ARCH_WIDTH});
138+ __sdata = .;
139+
131140 /* Must be called __global_pointer$ for linker relaxations to work. */
132141 PROVIDE(__global_pointer$ = . + 0x800);
133142 *(.sdata .sdata.* .sdata2 .sdata2.*);
134143 *(.data .data.*);
135- . = ALIGN(${ARCH_WIDTH});
136- _edata = .;
144+
137145 } > 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);
138155
139156 .bss (NOLOAD) : ALIGN(${ARCH_WIDTH})
140157 {
141- _sbss = .;
142- *(.sbss .sbss.* .bss .bss.*);
143158 . = ALIGN(${ARCH_WIDTH});
144- _ebss = .;
159+ __sbss = .;
160+
161+ *(.sbss .sbss.* .bss .bss.*);
145162 } > REGION_BSS
146163
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+
147170 /* fictitious region that represents the memory available for the heap */
148171 .heap (NOLOAD) :
149172 {
150- _sheap = .;
173+ __sheap = .;
151174 . += _heap_size;
152175 . = ALIGN(4);
153- _eheap = .;
176+ __eheap = .;
154177 } > REGION_HEAP
155178
156179 /* fictitious region that represents the memory available for the stack */
157180 .stack (NOLOAD) :
158181 {
159- _estack = .;
182+ __estack = .;
160183 . = ABSOLUTE(_stack_start);
161- _sstack = .;
184+ __sstack = .;
162185 } > REGION_STACK
163186
164187 /* fake output .got section */
@@ -190,16 +213,16 @@ ERROR(riscv-rt): the start of the REGION_STACK must be 4-byte aligned");
190213ASSERT(_stext % 4 == 0, "
191214ERROR(riscv-rt): `_stext` must be 4-byte aligned");
192215
193- ASSERT(_sdata % ${ARCH_WIDTH} == 0 && _edata % ${ARCH_WIDTH} == 0, "
216+ ASSERT(__sdata % ${ARCH_WIDTH} == 0 && __edata % ${ARCH_WIDTH} == 0, "
194217BUG(riscv-rt): .data is not ${ARCH_WIDTH}-byte aligned");
195218
196- ASSERT(_sidata % ${ARCH_WIDTH} == 0, "
219+ ASSERT(__sidata % ${ARCH_WIDTH} == 0, "
197220BUG(riscv-rt): the LMA of .data is not ${ARCH_WIDTH}-byte aligned");
198221
199- ASSERT(_sbss % ${ARCH_WIDTH} == 0 && _ebss % ${ARCH_WIDTH} == 0, "
222+ ASSERT(__sbss % ${ARCH_WIDTH} == 0 && __ebss % ${ARCH_WIDTH} == 0, "
200223BUG(riscv-rt): .bss is not ${ARCH_WIDTH}-byte aligned");
201224
202- ASSERT(_sheap % 4 == 0, "
225+ ASSERT(__sheap % 4 == 0, "
203226BUG(riscv-rt): start of .heap is not 4-byte aligned");
204227
205228ASSERT(_stext + SIZEOF(.text) < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "
0 commit comments