From: Petar Jovanovic Date: Fri, 27 Jan 2017 17:55:13 +0000 (+0000) Subject: mips: fix target_get_drv() function X-Git-Tag: svn/VALGRIND_3_13_0~209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa4577c0d53c215d9007dfd33a2bd53b76534d39;p=thirdparty%2Fvalgrind.git mips: fix target_get_drv() function Return correct Dtv location. Top of MIPS tcbhead structure is located 0x7000 bytes before the value of ULR. Dtv is the first of two pointers in the tcbhead structure. This fixes gdbserver_tests/hgtls on some MIPS platforms. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16212 --- diff --git a/coregrind/m_gdbserver/valgrind-low-mips32.c b/coregrind/m_gdbserver/valgrind-low-mips32.c index e44b635aca..300371db86 100644 --- a/coregrind/m_gdbserver/valgrind-low-mips32.c +++ b/coregrind/m_gdbserver/valgrind-low-mips32.c @@ -356,9 +356,11 @@ const char* target_xml (Bool shadow_mode) static CORE_ADDR** target_get_dtv (ThreadState *tst) { VexGuestMIPS32State* mips32 = (VexGuestMIPS32State*)&tst->arch.vex; - // mips32 dtv location similar to ppc64 - return (CORE_ADDR**)((CORE_ADDR)mips32->guest_ULR - - 0x7000 - sizeof(CORE_ADDR)); + // Top of MIPS tcbhead structure is located 0x7000 bytes before the value + // of ULR. Dtv is the first of two pointers in tcbhead structure. + // More details can be found in GLIBC/sysdeps/nptl/tls.h. + return (CORE_ADDR**)((CORE_ADDR)mips32->guest_ULR + - 0x7000 - 2 * sizeof(CORE_ADDR)); } static struct valgrind_target_ops low_target = { diff --git a/coregrind/m_gdbserver/valgrind-low-mips64.c b/coregrind/m_gdbserver/valgrind-low-mips64.c index f02bef70fc..4aac5743f8 100644 --- a/coregrind/m_gdbserver/valgrind-low-mips64.c +++ b/coregrind/m_gdbserver/valgrind-low-mips64.c @@ -357,9 +357,11 @@ const char* target_xml (Bool shadow_mode) static CORE_ADDR** target_get_dtv (ThreadState *tst) { VexGuestMIPS64State* mips64 = (VexGuestMIPS64State*)&tst->arch.vex; - // mips64 dtv location similar to ppc64 - return (CORE_ADDR**)((CORE_ADDR)mips64->guest_ULR - - 0x7000 - sizeof(CORE_ADDR)); + // Top of MIPS tcbhead structure is located 0x7000 bytes before the value + // of ULR. Dtv is the first of two pointers in tcbhead structure. + // More details can be found in GLIBC/sysdeps/nptl/tls.h. + return (CORE_ADDR**)((CORE_ADDR)mips64->guest_ULR + - 0x7000 - 2 * sizeof(CORE_ADDR)); } static struct valgrind_target_ops low_target = {