From f8e9c4d30c28b8815e65a391416e8b15d2e7cbb8 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Wed, 9 Mar 2016 00:25:00 +0100 Subject: [PATCH] mips: terminate the FDE before the return trampoline in makecontext In makecontext the FDE needs to be terminated before the return trampoline otherwise backtrace called within a context created by makecontext yields infinite backtrace. This bug has been present for a long time, stdlib/tst-makecontext did not fail until recent commit e535ce25. Tested on mips-linux-gnu and mips64el-linux-gnuabi64 and mips-linux-gnu, no regression. This fixes stdlib/tst-makecontext on MIPS. Changelog: [BZ #19792] * sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext): Terminate FDE before return label. --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/mips/makecontext.S | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index a6be76213e..727516e13b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-03-09 Aurelien Jarno + + [BZ #19792] + * sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext): + Terminate FDE before return label. + 2016-03-09 Joseph Myers [BZ #19790] diff --git a/sysdeps/unix/sysv/linux/mips/makecontext.S b/sysdeps/unix/sysv/linux/mips/makecontext.S index 66600c7513..31965543f8 100644 --- a/sysdeps/unix/sysv/linux/mips/makecontext.S +++ b/sysdeps/unix/sysv/linux/mips/makecontext.S @@ -153,6 +153,11 @@ NESTED (__makecontext, FRAMESZ, ra) #endif jr ra + /* We need to terminate the FDE to stop unwinding if backtrace was + called within a context created by makecontext. */ + cfi_endproc + nop + 99: #ifdef __PIC__ move gp, s1 @@ -186,6 +191,8 @@ NESTED (__makecontext, FRAMESZ, ra) 1: lb zero, (zero) b 1b + + cfi_startproc PSEUDO_END (__makecontext) weak_alias (__makecontext, makecontext)