diff options
author | rofl0r <retnyg@gmx.net> | 2012-11-19 06:21:48 +0100 |
---|---|---|
committer | rofl0r <retnyg@gmx.net> | 2012-11-19 16:58:09 +0100 |
commit | 3fae236e00068d17e007275717940f5d5e94ba1a (patch) | |
tree | cd95a0eb060b4e31cf8993e4ffd08fe9597e9689 | |
parent | 6c0cba819fb593f1efa33e0acd0bf59597279d97 (diff) | |
download | musl-3fae236e00068d17e007275717940f5d5e94ba1a.tar.gz musl-3fae236e00068d17e007275717940f5d5e94ba1a.tar.bz2 musl-3fae236e00068d17e007275717940f5d5e94ba1a.tar.xz musl-3fae236e00068d17e007275717940f5d5e94ba1a.zip |
powerpc: handle syscall error in clone.
sigsetjmp: store temporaries in jmp_buf rather than on stack.
-rw-r--r-- | src/signal/powerpc/sigsetjmp.s | 29 | ||||
-rw-r--r-- | src/thread/powerpc/clone.s | 34 |
2 files changed, 24 insertions, 39 deletions
diff --git a/src/signal/powerpc/sigsetjmp.s b/src/signal/powerpc/sigsetjmp.s index deed732f..a23463d2 100644 --- a/src/signal/powerpc/sigsetjmp.s +++ b/src/signal/powerpc/sigsetjmp.s @@ -10,25 +10,26 @@ 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, 12(1) - # store old link reg - mflr 0 - stw 0, 8(1) + # store non-volatile regs 30, 31 into the setjmp buf + stw 30, 0(3) + stw 31, 4(3) + # use them to store the pointer to the jmpbuf and the link reg + mr 30, 3 + mflr 31 + # 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 r3 - lwz 3, 12(1) - #restore link reg - lwz 0, 8(1) - mtlr 0 - #restore sp - addi 1, 1, 16 + + #restore jmpbuf pointer and link reg + mr 3, 30 + mtlr 31 + #resore non-volatile regs + lwz 30, 0(3) + lwz 31, 4(3) + 1: b setjmp diff --git a/src/thread/powerpc/clone.s b/src/thread/powerpc/clone.s index 54a2314e..dc5c74c6 100644 --- a/src/thread/powerpc/clone.s +++ b/src/thread/powerpc/clone.s @@ -13,12 +13,10 @@ __clone: # SYS_clone = 120 # SYS_exit = 1 -# in order that the child can find the start func and its arg, we need to store it into -# non-volative regs. to do so, we have to store those 2 regs into our stackframe, so -# we can restore them later. -subi 1, 1, 16 -stw 30, 12(1) -stw 31, 8(1) +# store non-volatile regs r30, r31 on stack in order to put our +# start func and its arg there +stwu 30, -16(1) +stw 31, 4(1) # save r3 (func) into r30, and r6(arg) into r31 mr 30, 3 @@ -37,19 +35,9 @@ li 0, 120 sc # check for syscall error -#this code should be more efficient, but it borks -#bns+ 1f # jump to label 1 if no summary overflow. +bns+ 1f # jump to label 1 if no summary overflow. #else -#neg 3, 3 #negate the result (errno) -#b 2f # jump to epilogue - -# this error check code at least does not spoil the clone call. -#mfcr 0 # Check for an error -#rlwinm 4, 0, 0, 3, 3 # by checking for bit 28. -#cmplwi 0, 4, 0 # It is an error if non-zero. -#beq 0, 1f # Jump if not an error. -#neg 3, 3 # Negate the error number. -#b 2f # jump to epilogue +neg 3, 3 #negate the result (errno) 1: # compare sc result with 0 cmpwi cr7, 3, 0 @@ -58,8 +46,7 @@ cmpwi cr7, 3, 0 bne cr7, 2f #else: we're the child -#call funcptr -# move arg (d) into r3 +#call funcptr: move arg (d) into r3 mr 3, 31 #move r30 (funcptr) into CTR reg mtctr 30 @@ -72,12 +59,9 @@ sc 2: # restore stack -lwz 30, 12(1) -lwz 31, 8(1) +lwz 30, 0(1) +lwz 31, 4(1) addi 1, 1, 16 blr - - - |