My colleague finds that there is probably a bug in handle_sys:
NESTED(handle_sys, PT_SIZE, sp)
lw t1, PT_EPC(sp) # skip syscall on return
sltiu t0, v0, MAX_SYSCALL_NO + 1 # check syscall number
addiu t1, 4 # skip to next instruction
beqz t0, illegal_syscall
sw t1, PT_EPC(sp)
This code is not guarded by .set no reorder,so it won't be the delay slot
instruction,thus illegal_syscall with num > MAX_SYSCALL_NO will return with
EPC unchanged. The reason it works is that the syscall number register
be changed to ENOSYS. ENOSYS is fortunately another illegal syscall number
that will take another illegal_syscall return path.
Newer glibc of debian(2.3.2+?) will generate sys_4246,and that lead to real
problem for mips64. Put the line ahead of the beqz solve it.