File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ #[ unsafe( no_mangle) ]
2+ #[ linkage = "weak" ]
3+ pub unsafe extern "C" fn abort ( ) -> ! {
4+ // On AVRs, an architecture that doesn't support traps, unreachable code
5+ // paths get lowered into calls to `abort`:
6+ //
7+ // https://github.com/llvm/llvm-project/blob/cbe8f3ad7621e402b050e768f400ff0d19c3aedd/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp#L4462
8+ //
9+ // When control gets here, it means an undefined behavior has occurred, so
10+ // there's really not that much we can do to recover - we can't reliably
11+ // `panic!()`, because for all we know the environment is gone, so panicking
12+ // might end up with us getting back to this very function.
13+ //
14+ // So let's do the next best thing, loop.
15+ //
16+ // Alternatively we could (try to) restart the program, but since undefined
17+ // behavior is undefined, there's really no obligation for us to do anything
18+ // here - for all we care, we could just set the chip on fire; but that'd be
19+ // bad for the environment.
20+
21+ loop { }
22+ }
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ pub mod aarch64_linux;
6363) ) ]
6464pub mod arm_linux;
6565
66+ #[ cfg( target_arch = "avr" ) ]
67+ pub mod avr;
68+
6669#[ cfg( target_arch = "hexagon" ) ]
6770pub mod hexagon;
6871
You can’t perform that action at this time.
0 commit comments