Skip to content

Commit fdb3078

Browse files
ByteFlowing1337StanFromIreland
authored andcommitted
[3.15] gh-151040: Fix test_c_stack_unwind on RISC-V (GH-152370)
(cherry picked from commit 1b0c05f) Co-authored-by: Ivy Xu <fakeshadow1337@gmail.com>
1 parent c86035c commit fdb3078

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Modules/_testinternalcapi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ static const uintptr_t min_frame_pointer_addr = 0x1000;
9898
// https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
9999
# define FRAME_POINTER_NEXT_OFFSET 0
100100
# define FRAME_POINTER_RETURN_OFFSET 2
101+
#elif defined(__riscv)
102+
// RISC-V saves the return address at fp[-1], and the previous frame pointer at fp[-2].
103+
// See: https://riscv-non-isa.github.io/riscv-elf-psabi-doc/#_frame_pointer_convention
104+
# define FRAME_POINTER_NEXT_OFFSET -2
105+
# define FRAME_POINTER_RETURN_OFFSET -1
101106
#else
102107
# define FRAME_POINTER_NEXT_OFFSET 0
103108
# define FRAME_POINTER_RETURN_OFFSET 1

0 commit comments

Comments
 (0)