From: Petar Jovanovic Date: Thu, 1 Dec 2016 16:01:45 +0000 (+0000) Subject: mips: fix call_on_new_stack_0_1 code X-Git-Tag: svn/VALGRIND_3_13_0~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7746f34db7b620cee440dc3bded19b6d62529b9b;p=thirdparty%2Fvalgrind.git mips: fix call_on_new_stack_0_1 code 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 --- diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index c85236c146..0aa85a16b0 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -77,41 +77,41 @@ 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" ); diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index 27d19bc7d9..6e3db740fb 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -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" );