Allocate additional space on stack for indirect syscall
The caller is only required to allocate 16 bytes on the stack for a0-a3. syscall is handling up to 6 arguments so additional space is needed on the stack to avoid corrupting the callers frame. Change-Id: I054b31696decc3e17d9c70af18cd278b852235d1
This commit is contained in:
parent
5e26221a1d
commit
766c7efe28
1 changed files with 8 additions and 0 deletions
|
@ -32,6 +32,12 @@
|
||||||
.align 4
|
.align 4
|
||||||
.ent syscall
|
.ent syscall
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The caller is only required to allocate 16 bytes of stack for a0-a3.
|
||||||
|
* syscall has up to 6 arguments, so we need space for the extra two arguments.
|
||||||
|
*/
|
||||||
|
#define STACKSIZE 2*4
|
||||||
|
|
||||||
syscall:
|
syscall:
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload $t9
|
.cpload $t9
|
||||||
|
@ -42,9 +48,11 @@ syscall:
|
||||||
lw $a3, 16($sp)
|
lw $a3, 16($sp)
|
||||||
lw $t0, 20($sp)
|
lw $t0, 20($sp)
|
||||||
lw $t1, 24($sp)
|
lw $t1, 24($sp)
|
||||||
|
subu $sp, STACKSIZE
|
||||||
sw $t0, 16($sp)
|
sw $t0, 16($sp)
|
||||||
sw $t1, 20($sp)
|
sw $t1, 20($sp)
|
||||||
syscall
|
syscall
|
||||||
|
addu $sp, STACKSIZE
|
||||||
bnez $a3, 1f
|
bnez $a3, 1f
|
||||||
move $a0, $v0
|
move $a0, $v0
|
||||||
j $ra
|
j $ra
|
||||||
|
|
Loading…
Reference in a new issue