@@ -458,7 +458,7 @@ use core::fmt;
458458// HardFault exceptions are bounced through this trampoline which grabs the stack pointer at
459459// the time of the exception and passes it to the user's HardFault handler in r0.
460460// Depending on the stack mode in EXC_RETURN, fetches stack from either MSP or PSP.
461- #[ cfg( cortex_m) ]
461+ #[ cfg( all ( cortex_m, feature = "hardfault-trampoline" ) ) ]
462462global_asm ! (
463463 ".cfi_sections .debug_frame
464464 .section .HardFaultTrampoline, \" ax\"
@@ -1061,12 +1061,22 @@ pub static __RESET_VECTOR: unsafe extern "C" fn() -> ! = Reset;
10611061#[ allow( unused_variables) ]
10621062#[ doc( hidden) ]
10631063#[ cfg_attr( cortex_m, link_section = ".HardFault.default" ) ]
1064+ #[ cfg( feature = "hardfault-trampoline" ) ]
10641065#[ no_mangle]
10651066pub unsafe extern "C" fn HardFault_ ( ef : & ExceptionFrame ) -> ! {
10661067 #[ allow( clippy:: empty_loop) ]
10671068 loop { }
10681069}
10691070
1071+ #[ doc( hidden) ]
1072+ #[ cfg_attr( cortex_m, link_section = ".HardFault.default" ) ]
1073+ #[ cfg( not( feature = "hardfault-trampoline" ) ) ]
1074+ #[ no_mangle]
1075+ pub unsafe extern "C" fn HardFault_ ( ) -> ! {
1076+ #[ allow( clippy:: empty_loop) ]
1077+ loop { }
1078+ }
1079+
10701080#[ doc( hidden) ]
10711081#[ no_mangle]
10721082pub unsafe extern "C" fn DefaultHandler_ ( ) -> ! {
@@ -1115,7 +1125,10 @@ extern "C" {
11151125
11161126 fn NonMaskableInt ( ) ;
11171127
1128+ #[ cfg( feature = "hardfault-trampoline" ) ]
11181129 fn HardFaultTrampoline ( ) ;
1130+ #[ cfg( not( feature = "hardfault-trampoline" ) ) ]
1131+ fn HardFault ( ) ;
11191132
11201133 #[ cfg( not( armv6m) ) ]
11211134 fn MemoryManagement ( ) ;
@@ -1154,9 +1167,12 @@ pub static __EXCEPTIONS: [Vector; 14] = [
11541167 handler : NonMaskableInt ,
11551168 } ,
11561169 // Exception 3: Hard Fault Interrupt.
1170+ #[ cfg( feature = "hardfault-trampoline" ) ]
11571171 Vector {
11581172 handler : HardFaultTrampoline ,
11591173 } ,
1174+ #[ cfg( not( feature = "hardfault-trampoline" ) ) ]
1175+ Vector { handler : HardFault } ,
11601176 // Exception 4: Memory Management Interrupt [not on Cortex-M0 variants].
11611177 #[ cfg( not( armv6m) ) ]
11621178 Vector {
0 commit comments