summaryrefslogtreecommitdiff
path: root/src/signal
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-18 22:57:32 -0500
committerRich Felker <dalias@aerifal.cx>2012-11-18 22:57:32 -0500
commit9565a349f217fb6f532fac06b7ef458a32c2ad2e (patch)
tree8c04bf07adcdc61315d71796331c971f281d5103 /src/signal
parent0004ea613ac310daaee30c167112d796db33fa70 (diff)
downloadmusl-9565a349f217fb6f532fac06b7ef458a32c2ad2e.tar.gz
fix powerpc asm not to store data in volatile space below stack pointer
it's essential to decrement the stack pointer before writing to new stack space, rather than afterwards. otherwise there is a race condition during which asynchronous code (signals) could clobber the data being stored. it may be possible to optimize the code further using stwu, but I wanted to avoid making any changes to the actual stack layout in this commit. further improvements can be made separately if desired.
Diffstat (limited to 'src/signal')
-rw-r--r--src/signal/powerpc/sigsetjmp.s16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/signal/powerpc/sigsetjmp.s b/src/signal/powerpc/sigsetjmp.s
index 81f5a40e..deed732f 100644
--- a/src/signal/powerpc/sigsetjmp.s
+++ b/src/signal/powerpc/sigsetjmp.s
@@ -10,25 +10,25 @@ sigsetjmp:
#2) if its 0, goto setjmp code
beq- cr7, 1f
#3) else: we must call pthread_sigmask(SIG_SETMASK, 0, (sigset_t *)buf->__ss);
+ # increase stack frame by 16
+ subi 1, 1, 16
# thus store r3 on the stack, to restore it later
- stw 3, -4(1)
+ stw 3, 12(1)
# store old link reg
mflr 0
- stw 0, -8(1)
- # increase stack frame by 16
- subi 1, 1, 16
+ stw 0, 8(1)
# put pointer to ss buf into r5 (3rd arg)
addi 5, 3, 260
# put "2" i.e. SIG_SETMASK in r3
li 3, 2
li 4, 0
bl pthread_sigmask
- #restore sp
- addi 1, 1, 16
#restore r3
- lwz 3, -4(1)
+ lwz 3, 12(1)
#restore link reg
- lwz 0, -8(1)
+ lwz 0, 8(1)
mtlr 0
+ #restore sp
+ addi 1, 1, 16
1:
b setjmp