diff --git a/src/stub/src/mipsel.r3000-linux.shlib-init.S b/src/stub/src/mipsel.r3000-linux.shlib-init.S index d5efc8da..4dd199db 100644 --- a/src/stub/src/mipsel.r3000-linux.shlib-init.S +++ b/src/stub/src/mipsel.r3000-linux.shlib-init.S @@ -71,7 +71,10 @@ AT_PAGESZ= 6 __NR_Linux = 4000 __NR_exit = 1+ __NR_Linux +__NR_read = 3+ __NR_Linux __NR_write = 4+ __NR_Linux +__NR_open = 5+ __NR_Linux +__NR_close = 6+ __NR_Linux __NR_mmap64 = 90+ __NR_Linux __NR_munmap = 91+ __NR_Linux __NR_mprotect = 125+ __NR_Linux @@ -104,7 +107,7 @@ DCACHE= 1<<1 #define UNFILTER 0 /* no unfilter for MIPS */ N_SLOTS= 0 -sp_frame = 24 * NBPW +sp_frame = 26 * NBPW .macro slot symbol, n .ifnb n N_SLOTS = \n + N_SLOTS @@ -126,34 +129,67 @@ pb_info= . - 1*NBPW // .long offset({p_info; b_info; compressed data}) slot f_envp slot f_argv slot f_argc + slot f_main + slot f_fd -_start: .globl _start // IN: jp= &_start; arg1= argc; arg2= argv; arg3= envp +_start: .globl _start // IN: jp= &_start +// If glibc: arg1= argc; arg2= argv; arg3= envp +// But musl: no args! //// break // for debugging addiu sp,sp,-sp_frame sw ra,f_my_ra(sp) sw arg3,f_envp(sp) sw arg2,f_argv(sp) sw arg1,f_argc(sp) + sw fp,f_fp(sp) -// Calculate PAGE_MASK -0: // Advance envp to auxp - lw v0,(arg3) - bnez v0,0b - addiu arg3,arg3,NBPW + li v0,%lo(_start) + subu jp,jp,v0 + addiu jp,jp,%lo(main) // jp= &main + sw jp,f_main(sp) + +// Determine PAGE_MASK + bal 0f + move a0,ra + .asciz "/proc/self/auxv" +bad_open: +bad_read: + li v1,1<