Skip to content

Commit 23be2d1

Browse files
Merge pull request #254 from rslawson/rs/lto-fixes
Remove weak symbols, use `abort` for defaults.
2 parents b970b91 + 58d4281 commit 23be2d1

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

Diff for: riscv-rt/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6262
allow users get the initial address of the heap when initializing an allocator.
6363
- Update documentation.
6464
- Removed `.init.rust` section, as it is no longer required.
65+
- Add global `_abort` symbol, `PROVIDE(abort = _abort)`, and replace `DefaultHandler` and
66+
`ExceptionHandler` with `PROVIDE(... = abort)`.
6567

6668
## [v0.13.0] - 2024-10-19
6769

Diff for: riscv-rt/link.x.in

+10-6
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@
2222
means that you won't see "Address (..) is out of bounds" in the disassembly produced by `objdump`.
2323
*/
2424

25+
/* Default abort entry point. If no abort symbol is provided, then abort maps to _abort. */
26+
EXTERN(_default_abort);
27+
PROVIDE(abort = _default_abort);
28+
2529
/* Default trap entry point. The riscv-rt crate provides a weak alias of this function,
2630
which saves caller saved registers, calls _start_trap_rust, restores caller saved registers
2731
and then returns. Users can override this alias by defining the symbol themselves */
2832
EXTERN(_start_trap);
2933

30-
/* Default exception handler. The riscv-rt crate provides a weak alias of this function,
31-
which is a busy loop. Users can override this alias by defining the symbol themselves */
32-
EXTERN(ExceptionHandler);
34+
/* Default exception handler. By default, the exception handler is abort.
35+
Users can override this alias by defining the symbol themselves */
36+
PROVIDE(ExceptionHandler = abort);
3337

34-
/* Default interrupt handler. The riscv-rt crate provides a weak alias of this function,
35-
which is a busy loop. Users can override this alias by defining the symbol themselves */
36-
EXTERN(DefaultHandler);
38+
/* Default interrupt handler. By default, the interrupt handler is abort.
39+
Users can override this alias by defining the symbol themselves */
40+
PROVIDE(DefaultHandler = abort);
3741

3842
/* Default interrupt trap entry point. When vectored trap mode is enabled,
3943
the riscv-rt crate provides an implementation of this function, which saves caller saved

Diff for: riscv-rt/src/asm.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,6 @@ _setup_interrupts:",
251251
#[cfg(not(feature = "s-mode"))]
252252
"csrw mtvec, t0",
253253
"ret",
254-
// Default implementation of `ExceptionHandler` is an infinite loop.
255-
// Users can override this function by defining their own `ExceptionHandler`
256-
".weak ExceptionHandler
257-
ExceptionHandler:
258-
j ExceptionHandler",
259-
// Default implementation of `DefaultHandler` is an infinite loop.
260-
// Users can override this function by defining their own `DefaultHandler`
261-
".weak DefaultHandler
262-
DefaultHandler:
263-
j DefaultHandler",
264254
// Default implementation of `_pre_init_trap` is an infinite loop.
265255
// Users can override this function by defining their own `_pre_init_trap`
266256
// If the execution reaches this point, it means that there is a bug in the boot code.
@@ -278,7 +268,7 @@ riscv_rt_macros::vectored_interrupt_trap!();
278268
#[rustfmt::skip]
279269
global_asm!(
280270
".section .text.abort
281-
.weak abort
282-
abort: // make sure there is an abort symbol when linking
283-
j abort"
271+
.global _default_abort
272+
_default_abort: // make sure there is an abort symbol when linking
273+
j _default_abort"
284274
);

0 commit comments

Comments
 (0)