aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2018-11-05 20:41:29 +0100
committerSegher Boessenkool <segher@gcc.gnu.org>2018-11-05 20:41:29 +0100
commitb40a67df7c5342204843f40f16ded89968bddd06 (patch)
treed8aa7cf14f4ec527541a85b989ba3b1f052c58a5
parent510e072da902bb3651dcfcdcee48d75e12ace6d6 (diff)
downloadgcc-b40a67df7c5342204843f40f16ded89968bddd06.zip
gcc-b40a67df7c5342204843f40f16ded89968bddd06.tar.gz
gcc-b40a67df7c5342204843f40f16ded89968bddd06.tar.bz2
Fix sanitizer frame unwind on 32-bit ABIs (again)
This re-applies r258525, and this time adds it to LOCAL_PATCHES. libsanitizer/ * LOCAL_PATCHES: Add r258525. * sanitizer_common/sanitizer_stacktrace.cc (BufferedStackTrace::FastUnwindStack): Use the correct frame offset for PowerPC SYSV ABI. From-SVN: r265817
-rw-r--r--libsanitizer/ChangeLog7
-rw-r--r--libsanitizer/LOCAL_PATCHES1
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_stacktrace.cc13
3 files changed, 18 insertions, 3 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 122fc02..b2dfda8 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,10 @@
+2018-11-05 Segher Boessenkool <segher@kernel.crashing.org>
+
+ * LOCAL_PATCHES: Add r258525.
+ * sanitizer_common/sanitizer_stacktrace.cc
+ (BufferedStackTrace::FastUnwindStack): Use the correct frame offset
+ for PowerPC SYSV ABI.
+
2018-11-05 Martin Liska <mliska@suse.cz>
PR sanitizer/87860
diff --git a/libsanitizer/LOCAL_PATCHES b/libsanitizer/LOCAL_PATCHES
index 56e74b8..06eb23e 100644
--- a/libsanitizer/LOCAL_PATCHES
+++ b/libsanitizer/LOCAL_PATCHES
@@ -1,3 +1,4 @@
+r258525
r265667
r265668
r265669
diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
index 699fd9f..aa74b70 100644
--- a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
@@ -82,14 +82,21 @@ void BufferedStackTrace::FastUnwindStack(uptr pc, uptr bp, uptr stack_top,
IsAligned((uptr)frame, sizeof(*frame)) &&
size < max_depth) {
#ifdef __powerpc__
- // PowerPC ABIs specify that the return address is saved at offset
- // 16 of the *caller's* stack frame. Thus we must dereference the
- // back chain to find the caller frame before extracting it.
+ // PowerPC ABIs specify that the return address is saved on the
+ // *caller's* stack frame. Thus we must dereference the back chain
+ // to find the caller frame before extracting it.
uhwptr *caller_frame = (uhwptr*)frame[0];
if (!IsValidFrame((uptr)caller_frame, stack_top, bottom) ||
!IsAligned((uptr)caller_frame, sizeof(uhwptr)))
break;
+ // For most ABIs the offset where the return address is saved is two
+ // register sizes. The exception is the SVR4 ABI, which uses an
+ // offset of only one register size.
+#ifdef _CALL_SYSV
+ uhwptr pc1 = caller_frame[1];
+#else
uhwptr pc1 = caller_frame[2];
+#endif
#elif defined(__s390__)
uhwptr pc1 = frame[14];
#else