[MIPS] syscall() segv on mips1

Khem Raj raj.khem at gmail.com
Fri Oct 24 07:03:18 UTC 2008


On Thu, Oct 23, 2008 at 9:12 PM, Maxime Bizon <mbizon at freebox.fr> wrote:
>
> On Thu, 2008-10-23 at 02:08 +0900, Atsushi Nemoto wrote:
>
> Hello Atsushi,
>
>> diff -u uClibc-0.9.30-rc2/libc/sysdeps/linux/mips/syscall.S uClibc/libc/sysdeps/linux/mips/syscall.S
>> --- uClibc-0.9.30-rc2/libc/sysdeps/linux/mips/syscall.S       2007-09-15 16:25:54.000000000 +0900
>> +++ uClibc/libc/sysdeps/linux/mips/syscall.S  2008-10-23 01:53:28.000000000 +0900
>> @@ -32,7 +32,6 @@
>>  #ifdef __PIC__
>>       SETUP_GP
>>  #endif
>> -     .set noreorder
>>       move    v0, a0          /* Load system call number from first arg.  */
>>       move    a0, a1          /* Move the next three args up a register.  */
>>       move    a1, a2
>> @@ -59,12 +58,12 @@
>>       lw      v0,7*4(sp)      /* for system call restarts */
>>  #endif
>>       syscall                 /* Do the system call.  */
>> -     bnez    a3, 1f
>>  #ifdef __mips64
>>       daddiu  sp,sp,16
>>  #else
>>       addiu   sp,sp,32
>>  #endif
>> +     bnez    a3, 1f
>>               j ra                    /* Return to caller.  */
>>  1:
>>       move    a0,v0           /* Pass return val to C function. */
>
> Thanks, it works for me (mips1), generated code:
>
> 00000000 <syscall>:
>   0:   3c1c0000        lui     gp,0x0
>                        0: R_MIPS_HI16  _gp_disp
>   4:   279c0000        addiu   gp,gp,0
>                        4: R_MIPS_LO16  _gp_disp
>   8:   0399e021        addu    gp,gp,t9
>   c:   00801021        move    v0,a0
>  10:   00a02021        move    a0,a1
>  14:   00c02821        move    a1,a2
>  18:   00e03021        move    a2,a3
>  1c:   8fa70010        lw      a3,16(sp)
>  20:   8fa80014        lw      t0,20(sp)
>  24:   8fa90018        lw      t1,24(sp)
>  28:   8faa001c        lw      t2,28(sp)
>  2c:   27bdffe0        addiu   sp,sp,-32
>  30:   afa80010        sw      t0,16(sp)
>  34:   afa90014        sw      t1,20(sp)
>  38:   afaa0018        sw      t2,24(sp)
>  3c:   afa2001c        sw      v0,28(sp)
>  40:   8fa2001c        lw      v0,28(sp)
>  44:   0000000c        syscall
>  48:   14e00003        bnez    a3,58 <syscall+0x58>
>  4c:   27bd0020        addiu   sp,sp,32
>  50:   03e00008        jr      ra
>  54:   00000000        nop
>  58:   00402021        move    a0,v0
>  5c:   8f990000        lw      t9,0(gp)
>                        5c: R_MIPS_CALL16       __syscall_error
>  60:   00000000        nop
>  64:   03200008        jr      t9
>  68:   00000000        nop
>  6c:   00000000        nop
>
> --
> Maxime
>
>


Maxime

Did you also add the nops as suggested or did you try the patch as such ?

Thanks

-Khem



More information about the uClibc mailing list