[compiler-rt] 51beb0c - [RISCV][ASAN] unwind fixup

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 01:13:31 PDT 2020


Author: Alexey Baturo
Date: 2020-10-04T11:13:12+03:00
New Revision: 51beb0c80dc45d45efada5cd6e3a13c9fef0805c

URL: https://github.com/llvm/llvm-project/commit/51beb0c80dc45d45efada5cd6e3a13c9fef0805c
DIFF: https://github.com/llvm/llvm-project/commit/51beb0c80dc45d45efada5cd6e3a13c9fef0805c.diff

LOG: [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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
index ca2f90a51c9e..e51609f54a0a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
@@ -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);
   }
 }
 


        


More information about the llvm-commits mailing list