Author: Saleem Abdulrasool Date: 2021-08-02T16:36:37Z New Revision: d6d0b6559e97a3d0b258814e870d3e19f3a7ffcc
URL: https://github.com/llvm/llvm-project/commit/d6d0b6559e97a3d0b258814e870d3e19f3a7ffcc DIFF: https://github.com/llvm/llvm-project/commit/d6d0b6559e97a3d0b258814e870d3e19f3a7ffcc.diff LOG: unwind: repair register restoration for OR1K Currently, OR1K architecture put the program counter at offset 0x128 of the current `or1k_thread_state_t`. However, the PC is restored after updating the thread pointer in `r3`, which causes the PC to be fetched incorrectly. This patch swaps the order of restoration of `r9` and `r3`, such that the PC is restored to `r9` using the current thread state. Patch by Oi Chee Cheung! Reviewed By: whitequark, compnerd Differential Revision: https://reviews.llvm.org/D107042 Added: Modified: libunwind/src/UnwindRegistersRestore.S Removed: ################################################################################ diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S index d8bf1adee4168..c2106f32ee9f0 100644 --- a/libunwind/src/UnwindRegistersRestore.S +++ b/libunwind/src/UnwindRegistersRestore.S @@ -800,11 +800,12 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) l.lwz r30,120(r3) l.lwz r31,124(r3) + # load new pc into ra + l.lwz r9, 128(r3) + # at last, restore r3 l.lwz r3, 12(r3) - # load new pc into ra - l.lwz r9, 128(r3) # jump to pc l.jr r9 l.nop _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits