@@ -127,6 +127,16 @@ PROVIDE(_max_hart_id = 0);
127127PROVIDE(_hart_stack_size = SIZEOF(.stack) / (_max_hart_id + 1));
128128PROVIDE(_heap_size = 0);
129129
130+ {% set trap_regions %}
131+ . = ALIGN(4);
132+ KEEP(*(.trap.vector)); /* for _trap_vector (vectored mode only) */
133+ KEEP(*(.trap.start)); /* for _start_trap routine */
134+ KEEP(*(.trap.start.*)); /* for _start_INTERRUPT_trap routines (vectored mode only) */
135+ KEEP(*(.trap.continue)); /* for _continue_trap routine (vectored mode only) */
136+ KEEP(*(.trap.rust)); /* for _start_trap_rust Rust function */
137+ KEEP(*(.trap .trap.*)); /* Other .trap symbols at the end */
138+ {% endset %}
139+
130140SECTIONS
131141{
132142 .text.dummy (NOLOAD) :
@@ -143,14 +153,9 @@ SECTIONS
143153 /* point of the program. */
144154 KEEP(*(.init));
145155
146- . = ALIGN(4);
147- KEEP(*(.trap.vector)); /* for _trap_vector (vectored mode only) */
148- KEEP(*(.trap.start)); /* for _start_trap routine */
149- KEEP(*(.trap.start.*)); /* for _start_INTERRUPT_trap routines (vectored mode only) */
150- KEEP(*(.trap.continue)); /* for _continue_trap routine (vectored mode only) */
151- KEEP(*(.trap.rust)); /* for _start_trap_rust Rust function */
152- KEEP(*(.trap .trap.*)); /* Other .trap symbols at the end */
153-
156+ {% if not contains(cfg.feature, "trap-region") %}
157+ {{ trap_regions }}
158+ {% endif %}
154159 *(.text.abort);
155160 *(.text .text.*);
156161
@@ -173,6 +178,13 @@ SECTIONS
173178 __erodata = .;
174179 } > REGION_RODATA
175180
181+ {% if contains(cfg.feature, "trap-region") %}
182+ .trap : ALIGN(4)
183+ {
184+ {{ trap_regions }}
185+ } > REGION_TRAP
186+ {% endif %}
187+
176188 .data : ALIGN({{ cfg.arch_width }})
177189 {
178190 . = ALIGN({{ cfg.arch_width }});
0 commit comments