summaryrefslogtreecommitdiff
path: root/sysdeps/s390
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.vnet.ibm.com>2017-11-21 08:45:28 +0100
committerStefan Liebler <stli@linux.vnet.ibm.com>2017-11-21 08:45:28 +0100
commit8beba15d536aa5c89e9e55e4c497c0bcd10cb67c (patch)
tree69242ba27abfd4ca52b62a43e5c5f47264f47171 /sysdeps/s390
parent80eb52e3a93a9f611a415a3565d17536cf023f8a (diff)
S390: Add cfi information for start routines in order to stop unwinding.
GDB failed to detect the outermost frame while showing the backtrace within a thread: Backtrace stopped: previous frame identical to this frame (corrupt stack?) Before this patch, the start routines like thread_start had no cfi information. GDB is then using the prologue unwinder if no cfi information is available. This unwinder tries to unwind r15 and stops e.g. if r15 was updated or on some jump-instructions. On older glibc-versions (before commit "Remove cached PID/TID in clone" c579f48edba88380635ab98cb612030e3ed8691e), the thread_start function used such a jump-instruction and GDB did not fail with an error. This patch adds cfi information for _start, thread_start and __makecontext_ret and marks r14 as undefined which marks the frame as outermost frame and GDB stops the backtrace. Also tested different gcc versions in order to test _Unwind_Backtrace() in libgcc as this is used by backtrace() in glibc. ChangeLog: * sysdeps/s390/s390-64/start.S (_start): Add cfi information for r14. * sysdeps/s390/s390-32/start.S: (_start): Likewise * sysdeps/unix/sysv/linux/s390/s390-64/clone.S (thread_start): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/clone.S (thread_start): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S (__makecontext_ret): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S (__makecontext_ret): Likewise.
Diffstat (limited to 'sysdeps/s390')
-rw-r--r--sysdeps/s390/s390-32/start.S7
-rw-r--r--sysdeps/s390/s390-64/start.S7
2 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S
index 07400f1752..66c00f3b0a 100644
--- a/sysdeps/s390/s390-32/start.S
+++ b/sysdeps/s390/s390-32/start.S
@@ -34,6 +34,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <sysdep.h>
+
/*
This is the canonical entry point, usually the first thing in the text
segment. Most registers' values are unspecified, except for:
@@ -57,6 +59,10 @@
.globl _start
.type _start,@function
_start:
+ cfi_startproc
+ /* Mark r14 as undefined in order to stop unwinding here! */
+ cfi_undefined (r14)
+
/* Check if the kernel provides highgprs facility if needed by
the binary. */
@@ -188,6 +194,7 @@ _start:
/* crash if __libc_start_main returns */
.word 0
+ cfi_endproc
.Llit:
#ifndef PIC
.L1: .long __libc_csu_init
diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S
index d8e65450d8..d3e62d2ec7 100644
--- a/sysdeps/s390/s390-64/start.S
+++ b/sysdeps/s390/s390-64/start.S
@@ -34,6 +34,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <sysdep.h>
+
/*
This is the canonical entry point, usually the first thing in the text
segment. Most registers' values are unspecified, except for:
@@ -57,6 +59,9 @@
.globl _start
.type _start,@function
_start:
+ cfi_startproc
+ /* Mark r14 as undefined in order to stop unwinding here! */
+ cfi_undefined (r14)
/* Load argc and argv from stack. */
la %r4,8(%r15) # get argv
lg %r3,0(%r15) # get argc
@@ -91,6 +96,8 @@ _start:
/* Crash if __libc_start_main returns. */
.word 0
+ cfi_endproc
+
/* Define a symbol for the first piece of initialized data. */
.data
.globl __data_start