valgrind/vg_bug259977_r11688.patch

200 lines
6.5 KiB
Diff

Index: memcheck/mc_leakcheck.c
===================================================================
--- memcheck/mc_leakcheck.c (revision 11687)
+++ memcheck/mc_leakcheck.c (revision 11688)
@@ -635,7 +635,7 @@
}
-static VG_MINIMAL_JMP_BUF memscan_jmpbuf;
+static VG_MINIMAL_JMP_BUF(memscan_jmpbuf);
static
void scan_all_valid_memory_catcher ( Int sigNo, Addr addr )
Index: include/pub_tool_libcsetjmp.h
===================================================================
--- include/pub_tool_libcsetjmp.h (revision 11687)
+++ include/pub_tool_libcsetjmp.h (revision 11688)
@@ -64,10 +64,21 @@
second function (eg, VG_(minimal_setjmp)) doesn't seem to work for
whatever reason -- returns via a VG_(minimal_longjmp) go wrong.
*/
-#define VG_MINIMAL_JMP_BUF jmp_buf
+
+#if defined(VGP_ppc32_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) UInt _name [32+1+1]
+Int VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#else
+
+/* The default implementation. */
+#define VG_MINIMAL_JMP_BUF(_name) jmp_buf _name
#define VG_MINIMAL_SETJMP(_env) __builtin_setjmp((_env))
#define VG_MINIMAL_LONGJMP(_env) __builtin_longjmp((_env),1)
+#endif
#endif // __PUB_TOOL_LIBCSETJMP_H
Index: coregrind/m_libcsetjmp.c
===================================================================
--- coregrind/m_libcsetjmp.c (revision 11687)
+++ coregrind/m_libcsetjmp.c (revision 11688)
@@ -36,9 +36,114 @@
/* See include/pub_tool_libcsetjmp.h for background and rationale. */
-/* No alternative implementations at present. */
+/* The only alternative implementations are for ppc{32,64}-linux. See
+ #259977. */
+#if defined(VGP_ppc32_linux)
+__asm__(
+".text" "\n"
+"" "\n"
+".global VG_MINIMAL_SETJMP" "\n" // r3 = jmp_buf
+"VG_MINIMAL_SETJMP:" "\n"
+" stw 0, 0(3)" "\n"
+" stw 1, 4(3)" "\n"
+" stw 2, 8(3)" "\n"
+" stw 3, 12(3)" "\n"
+" stw 4, 16(3)" "\n"
+" stw 5, 20(3)" "\n"
+" stw 6, 24(3)" "\n"
+" stw 7, 28(3)" "\n"
+" stw 8, 32(3)" "\n"
+" stw 9, 36(3)" "\n"
+" stw 10, 40(3)" "\n"
+" stw 11, 44(3)" "\n"
+" stw 12, 48(3)" "\n"
+" stw 13, 52(3)" "\n"
+" stw 14, 56(3)" "\n"
+" stw 15, 60(3)" "\n"
+" stw 16, 64(3)" "\n"
+" stw 17, 68(3)" "\n"
+" stw 18, 72(3)" "\n"
+" stw 19, 76(3)" "\n"
+" stw 20, 80(3)" "\n"
+" stw 21, 84(3)" "\n"
+" stw 22, 88(3)" "\n"
+" stw 23, 92(3)" "\n"
+" stw 24, 96(3)" "\n"
+" stw 25, 100(3)" "\n"
+" stw 26, 104(3)" "\n"
+" stw 27, 108(3)" "\n"
+" stw 28, 112(3)" "\n"
+" stw 29, 116(3)" "\n"
+" stw 30, 120(3)" "\n"
+" stw 31, 124(3)" "\n"
+ // must use a caller-save register here as scratch, hence r4
+" mflr 4" "\n"
+" stw 4, 128(3)" "\n"
+" mfcr 4" "\n"
+" stw 4, 132(3)" "\n"
+" li 3, 0" "\n"
+" blr" "\n"
+"" "\n"
+
+
+".global VG_MINIMAL_LONGJMP" "\n"
+"VG_MINIMAL_LONGJMP:" "\n" // r3 = jmp_buf
+ // do r4 = 1
+ // and park it in the restore slot for r3 (the ret reg)
+" li 4, 1" "\n"
+" stw 4, 12(3)" "\n"
+ // restore everything except r3
+ // then r3 last of all
+ // then blr
+" lwz 0, 128(3)" "\n"
+" mtlr 0" "\n"
+" lwz 0, 132(3)" "\n"
+" mtcr 0" "\n"
+" lwz 0, 0(3)" "\n"
+" lwz 1, 4(3)" "\n"
+" lwz 2, 8(3)" "\n"
+ // r3 is done at the end
+" lwz 4, 16(3)" "\n"
+" lwz 5, 20(3)" "\n"
+" lwz 6, 24(3)" "\n"
+" lwz 7, 28(3)" "\n"
+" lwz 8, 32(3)" "\n"
+" lwz 9, 36(3)" "\n"
+" lwz 10, 40(3)" "\n"
+" lwz 11, 44(3)" "\n"
+" lwz 12, 48(3)" "\n"
+" lwz 13, 52(3)" "\n"
+" lwz 14, 56(3)" "\n"
+" lwz 15, 60(3)" "\n"
+" lwz 16, 64(3)" "\n"
+" lwz 17, 68(3)" "\n"
+" lwz 18, 72(3)" "\n"
+" lwz 19, 76(3)" "\n"
+" lwz 20, 80(3)" "\n"
+" lwz 21, 84(3)" "\n"
+" lwz 22, 88(3)" "\n"
+" lwz 23, 92(3)" "\n"
+" lwz 24, 96(3)" "\n"
+" lwz 25, 100(3)" "\n"
+" lwz 26, 104(3)" "\n"
+" lwz 27, 108(3)" "\n"
+" lwz 28, 112(3)" "\n"
+" lwz 29, 116(3)" "\n"
+" lwz 30, 120(3)" "\n"
+" lwz 31, 124(3)" "\n"
+" lwz 3, 12(3)" "\n"
+" blr" "\n"
+"" "\n"
+
+
+".previous" "\n"
+);
+
+#endif /* VGP_ppc32_linux */
+
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Index: coregrind/m_machine.c
===================================================================
--- coregrind/m_machine.c (revision 11687)
+++ coregrind/m_machine.c (revision 11688)
@@ -423,7 +423,7 @@
#if defined(VGA_ppc32) || defined(VGA_ppc64) \
|| defined(VGA_arm) || defined(VGA_s390x)
#include "pub_tool_libcsetjmp.h"
-static VG_MINIMAL_JMP_BUF env_unsup_insn;
+static VG_MINIMAL_JMP_BUF(env_unsup_insn);
static void handler_unsup_insn ( Int x ) {
VG_MINIMAL_LONGJMP(env_unsup_insn);
}
Index: coregrind/m_debuginfo/readdwarf3.c
===================================================================
--- coregrind/m_debuginfo/readdwarf3.c (revision 11687)
+++ coregrind/m_debuginfo/readdwarf3.c (revision 11688)
@@ -3955,7 +3955,7 @@
static Bool d3rd_jmpbuf_valid = False;
static HChar* d3rd_jmpbuf_reason = NULL;
-static VG_MINIMAL_JMP_BUF d3rd_jmpbuf;
+static VG_MINIMAL_JMP_BUF(d3rd_jmpbuf);
static __attribute__((noreturn)) void barf ( HChar* reason ) {
vg_assert(d3rd_jmpbuf_valid);
Index: coregrind/pub_core_threadstate.h
===================================================================
--- coregrind/pub_core_threadstate.h (revision 11687)
+++ coregrind/pub_core_threadstate.h (revision 11688)
@@ -356,7 +356,7 @@
/* Per-thread jmp_buf to resume scheduler after a signal */
Bool sched_jmpbuf_valid;
- VG_MINIMAL_JMP_BUF sched_jmpbuf;
+ VG_MINIMAL_JMP_BUF(sched_jmpbuf);
}
ThreadState;