@@ -447,7 +447,7 @@ core::arch::global_asm!(
447447 _asm_default_undefined_handler:
448448 // state save from compiled code
449449 srsfd sp!, {und_mode}
450- // to work out what mode we're in, we need R0
450+ // to work out what mode we're in, we need R0, so save it
451451 push {{r0}}
452452 // First adjust LR for two purposes: Passing the faulting instruction to the C handler,
453453 // and to return to the failing instruction after the C handler returns.
@@ -459,7 +459,7 @@ core::arch::global_asm!(
459459 ite eq
460460 subeq lr, lr, #4
461461 subne lr, lr, #2
462- // now do our standard exception save
462+ // now do our standard exception save (which saves the 'wrong' R0)
463463 "# ,
464464 save_context!( ) ,
465465 r#"
@@ -469,15 +469,15 @@ core::arch::global_asm!(
469469 bl _undefined_handler
470470 // if we get back here, assume they returned a new LR in r0
471471 mov lr, r0
472- // do our standard restore
472+ // do our standard restore (with the 'wrong' R0)
473473 "# ,
474474 restore_context!( ) ,
475475 r#"
476- // get our real saved R0
476+ // get the R0 we saved early
477477 pop {{r0}}
478- // overwrite the saved LR with the adjusted one
478+ // overwrite the saved LR with the one from the C handler
479479 str lr, [sp]
480- // Return to the failing instruction which is the recommended approach by ARM.
480+ // Return from the asm handler
481481 rfefd sp!
482482 .size _asm_default_undefined_handler, . - _asm_default_undefined_handler
483483
@@ -533,9 +533,9 @@ core::arch::global_asm!(
533533 "# ,
534534 restore_context!( ) ,
535535 r#"
536- // overwrite the saved LR with the adjusted one
536+ // overwrite the saved LR with the one from the C handler
537537 str lr, [sp]
538- // Return to the failing instruction which is the recommended approach by ARM.
538+ // Return from the asm handler
539539 rfefd sp!
540540 .size _asm_default_abort_handler, . - _asm_default_abort_handler
541541
@@ -564,9 +564,9 @@ core::arch::global_asm!(
564564 "# ,
565565 restore_context!( ) ,
566566 r#"
567- // overwrite the saved LR with the adjusted one
567+ // overwrite the saved LR with the one from the C handler
568568 str lr, [sp]
569- // Return to the failing instruction which is the recommended approach by ARM.
569+ // Return from the asm handler
570570 rfefd sp!
571571 .size _asm_default_prefetch_handler, . - _asm_default_prefetch_handler
572572
0 commit comments