]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix sanitizer frame unwind on 32-bit ABIs (again)
authorsegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Nov 2018 19:41:29 +0000 (19:41 +0000)
committersegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Nov 2018 19:41:29 +0000 (19:41 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265817 138bc75d-0d04-0410-961f-82ee72b054a4

libsanitizer/ChangeLog
libsanitizer/LOCAL_PATCHES
libsanitizer/sanitizer_common/sanitizer_stacktrace.cc

index 122fc022308eca879f5c1b6bcd6e3155f7f6b6ed..b2dfda871a9701a5f6b7aaac1cae95365cba61b8 100644 (file)
@@ -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
index 56e74b8b73a37f49d64d234c5b1242e510079761..06eb23efab1c39231495ac013c95707dc0b455cc 100644 (file)
@@ -1,3 +1,4 @@
+r258525
 r265667
 r265668
 r265669
index 699fd9fdce07b670a903745fb6603e0867a0fc8c..aa74b7099e14790da79e58ea0f4293ae2569364b 100644 (file)
@@ -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