]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: fix target_get_drv() function
authorPetar Jovanovic <mips32r2@gmail.com>
Fri, 27 Jan 2017 17:55:13 +0000 (17:55 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Fri, 27 Jan 2017 17:55:13 +0000 (17:55 +0000)
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

coregrind/m_gdbserver/valgrind-low-mips32.c
coregrind/m_gdbserver/valgrind-low-mips64.c

index e44b635aca822c8ceae1e0650054b9249aad91a2..300371db868ebce7406c99abc4a28f2dc3aacd66 100644 (file)
@@ -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 = {
index f02bef70fccbd6baa8c62cbb8ec3aa87691ef2ea..4aac5743f8152479b155756ef71d00039f33a276 100644 (file)
@@ -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 = {