]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: fix call_on_new_stack_0_1 code
authorPetar Jovanovic <mips32r2@gmail.com>
Thu, 1 Dec 2016 16:01:45 +0000 (16:01 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Thu, 1 Dec 2016 16:01:45 +0000 (16:01 +0000)
MIPS32 implementation missed to set up a correct (zero) return address.
This led to incorrect execution of get_StackTrace_wrk as it was not
able to unwind stack correctly.
This change fixes memcheck/tests/leak-autofreepool-5.

MIPS64 implementation missed clearing all integer registers before
entering the function.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16166

coregrind/m_syswrap/syswrap-mips32-linux.c
coregrind/m_syswrap/syswrap-mips64-linux.c

index c85236c14682513584da8cb9c07d636855860357..0aa85a16b03943f50440bf9bf8bfe298826d5d8a 100644 (file)
    stack, and use 'retaddr' as f's return-to address.  Also, clear all
    the integer registers before entering f.*/ 
 
-__attribute__ ((noreturn)) 
-void ML_ (call_on_new_stack_0_1) (Addr stack, Addr retaddr, 
+__attribute__ ((noreturn))
+void ML_ (call_on_new_stack_0_1) (Addr stack, Addr retaddr,
                                   void (*f) (Word), Word arg1);
 //    a0 = stack
 //    a1 = retaddr
 //    a2 = f
 //    a3 = arg1
 asm (
-".text\n" 
-".globl vgModuleLocal_call_on_new_stack_0_1\n" 
+".text\n"
+".globl vgModuleLocal_call_on_new_stack_0_1\n"
 "vgModuleLocal_call_on_new_stack_0_1:\n" 
-"   move       $29, $4\n\t"    // stack to %sp
-"   move       $25, $6\n\t"    // f to t9/$25 
-"   move       $4, $7\n\t"     // arg1 to $a0
-"   li                 $2, 0\n\t"      // zero all GP regs
-"   li                 $3, 0\n\t" 
-"   li                 $5, 0\n\t" 
-"   li                 $6, 0\n\t" 
-"   li                 $7, 0\n\t" 
-
-"   li                 $12, 0\n\t" 
-"   li                 $13, 0\n\t" 
-"   li                 $14, 0\n\t" 
-"   li                 $15, 0\n\t" 
-"   li                 $16, 0\n\t" 
-"   li                 $17, 0\n\t" 
-"   li                 $18, 0\n\t" 
-"   li                 $19, 0\n\t" 
-"   li                 $20, 0\n\t" 
-"   li                 $21, 0\n\t" 
-"   li                 $22, 0\n\t" 
-"   li                 $23, 0\n\t" 
-"   li                 $24, 0\n\t" 
-"   jr                 $25\n\t"        // jump to dst
-"   break      0x7\n"  // should never get here
+"   move  $29, $4\n\t"  // stack to %sp
+"   move  $31, $5\n\t"  // retaddr to $ra
+"   move  $25, $6\n\t"  // f to t9/$25
+"   move  $4, $7\n\t"   // arg1 to $a0
+"   li    $2, 0\n\t"    // zero all GP regs
+"   li    $3, 0\n\t"
+"   li    $5, 0\n\t"
+"   li    $6, 0\n\t"
+"   li    $7, 0\n\t"
+"   li    $12, 0\n\t"
+"   li    $13, 0\n\t"
+"   li    $14, 0\n\t"
+"   li    $15, 0\n\t"
+"   li    $16, 0\n\t"
+"   li    $17, 0\n\t"
+"   li    $18, 0\n\t"
+"   li    $19, 0\n\t"
+"   li    $20, 0\n\t"
+"   li    $21, 0\n\t"
+"   li    $22, 0\n\t"
+"   li    $23, 0\n\t"
+"   li    $24, 0\n\t"
+"   jr    $25\n\t"      // jump to dst
+"   break 0x7\n"        // should never get here
 ".previous\n" 
 );
 
index 27d19bc7d98490a3d81ea547622d4b0852b08a3f..6e3db740fbf0162de4bfaeb7b52dc10cb54e57c2 100644 (file)
@@ -84,12 +84,30 @@ asm (
 ".text\n"
 ".globl vgModuleLocal_call_on_new_stack_0_1\n"
 "vgModuleLocal_call_on_new_stack_0_1:\n"
-"   move $29, $4\n"  /* set stack */
-"   move $4,  $7\n"  /* arg1 to $4 */
+"   move $29, $4\n"   /* set stack */
+"   move $4,  $7\n"   /* arg1 to $4 */
 "   move $25, $6\n"
-"   move $31, $5\n"  /* retaddr to $ra */
-"   jr $25\n"        /* jump to f */
-"   break 0x7\n"     /* should never get here */
+"   move $31, $5\n"   /* retaddr to $ra */
+"   li   $2, 0\n\t"   /* zero all GP regs */
+"   li   $3, 0\n\t"
+"   li   $5, 0\n\t"
+"   li   $6, 0\n\t"
+"   li   $7, 0\n\t"
+"   li   $12, 0\n\t"
+"   li   $13, 0\n\t"
+"   li   $14, 0\n\t"
+"   li   $15, 0\n\t"
+"   li   $16, 0\n\t"
+"   li   $17, 0\n\t"
+"   li   $18, 0\n\t"
+"   li   $19, 0\n\t"
+"   li   $20, 0\n\t"
+"   li   $21, 0\n\t"
+"   li   $22, 0\n\t"
+"   li   $23, 0\n\t"
+"   li   $24, 0\n\t"
+"   jr $25\n"         /* jump to f */
+"   break 0x7\n"      /* should never get here */
 ".previous\n"
 );