[RISCV][ASAN] unwind fixup

[8/11] patch series to port ASAN for riscv64

Depends On D87577

Reviewed By: eugenis, vitalybuka

Differential Revision: https://reviews.llvm.org/D87579
This commit is contained in:
Alexey Baturo 2020-10-04 10:31:30 +03:00 committed by apink
parent 0f08a1a5b1
commit 51beb0c80d
1 changed files with 10 additions and 1 deletions

View File

@ -116,6 +116,9 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
uhwptr pc1 = caller_frame[2];
#elif defined(__s390__)
uhwptr pc1 = frame[14];
#elif defined(__riscv)
// frame[-1] contains the return address
uhwptr pc1 = frame[-1];
#else
uhwptr pc1 = frame[1];
#endif
@ -128,7 +131,13 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
trace_buffer[size++] = (uptr) pc1;
}
bottom = (uptr)frame;
frame = GetCanonicFrame((uptr)frame[0], stack_top, bottom);
#if defined(__riscv)
// frame[-2] contain fp of the previous frame
uptr new_bp = (uptr)frame[-2];
#else
uptr new_bp = (uptr)frame[0];
#endif
frame = GetCanonicFrame(new_bp, stack_top, bottom);
}
}