diff options
author | Stefan Liebler <stli@linux.vnet.ibm.com> | 2017-11-21 08:45:28 +0100 |
---|---|---|
committer | Stefan Liebler <stli@linux.vnet.ibm.com> | 2017-11-21 08:45:28 +0100 |
commit | 8beba15d536aa5c89e9e55e4c497c0bcd10cb67c (patch) | |
tree | 69242ba27abfd4ca52b62a43e5c5f47264f47171 /sysdeps/unix/sysv/linux | |
parent | 80eb52e3a93a9f611a415a3565d17536cf023f8a (diff) | |
download | glibc-8beba15d536aa5c89e9e55e4c497c0bcd10cb67c.tar glibc-8beba15d536aa5c89e9e55e4c497c0bcd10cb67c.tar.gz glibc-8beba15d536aa5c89e9e55e4c497c0bcd10cb67c.tar.bz2 glibc-8beba15d536aa5c89e9e55e4c497c0bcd10cb67c.zip |
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/unix/sysv/linux')
4 files changed, 12 insertions, 16 deletions
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S b/sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S index 887d841a87..ba38a303ee 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S +++ b/sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S @@ -17,15 +17,9 @@ #include <sysdep.h> -/* We do not want .eh_frame info so that __makecontext_ret stops unwinding - if backtrace was called within a context created by makecontext. (There - is also no .eh_frame info for _start or thread_start.) */ -#undef cfi_startproc -#define cfi_startproc -#undef cfi_endproc -#define cfi_endproc - ENTRY(__makecontext_ret) + /* Mark r14 as undefined in order to stop unwinding here! */ + cfi_undefined (r14) basr %r14,%r7 ltr %r8,%r8 /* Check whether uc_link is 0. */ jz 1f diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S index a8b4dbc90f..91f8ede966 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S +++ b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S @@ -54,12 +54,16 @@ error: PSEUDO_END (__clone) thread_start: + cfi_startproc + /* Mark r14 as undefined in order to stop unwinding here! */ + cfi_undefined (r14) /* fn is in gpr 1, arg in gpr 0 */ lr %r2,%r0 /* set first parameter to void *arg */ ahi %r15,-96 /* make room on the stack for the save area */ xc 0(4,%r15),0(%r15) basr %r14,%r1 /* jump to fn */ DO_CALL (exit, 1) + cfi_endproc libc_hidden_def (__clone) weak_alias (__clone, clone) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S b/sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S index 16901638b5..2dcd43ff6e 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S +++ b/sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S @@ -17,15 +17,9 @@ #include <sysdep.h> -/* We do not want .eh_frame info so that __makecontext_ret stops unwinding - if backtrace was called within a context created by makecontext. (There - is also no .eh_frame info for _start or thread_start.) */ -#undef cfi_startproc -#define cfi_startproc -#undef cfi_endproc -#define cfi_endproc - ENTRY(__makecontext_ret) + /* Mark r14 as undefined in order to stop unwinding here! */ + cfi_undefined (r14) basr %r14,%r7 ltgr %r8,%r8 /* Check whether uc_link is 0. */ jz 1f diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S index daf8a58326..8b0cc7e019 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S +++ b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S @@ -55,12 +55,16 @@ error: PSEUDO_END (__clone) thread_start: + cfi_startproc + /* Mark r14 as undefined in order to stop unwinding here! */ + cfi_undefined (r14) /* fn is in gpr 1, arg in gpr 0 */ lgr %r2,%r0 /* set first parameter to void *arg */ aghi %r15,-160 /* make room on the stack for the save area */ xc 0(8,%r15),0(%r15) basr %r14,%r1 /* jump to fn */ DO_CALL (exit, 1) + cfi_endproc libc_hidden_def (__clone) weak_alias (__clone, clone) |