[PATCH for valgrind] coregrind: implement GS override for arch_prctl on linux

Maarten Lankhorst m.b.lankhorst at gmail.com
Wed Jan 30 12:50:10 CST 2013


Allows wine64 to run in valgrind! Apply with -Np0. :D

Yes I know that %gs is still zero on linux amd64. Details details..

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at ubuntu.com>

---

Index: coregrind/m_translate.c
===================================================================
--- coregrind/m_translate.c	(revision 13279)
+++ coregrind/m_translate.c	(working copy)
@@ -1486,7 +1486,7 @@
 #  if defined(VGP_amd64_linux)
    vex_abiinfo.guest_amd64_assume_fs_is_zero  = True;
 #  endif
-#  if defined(VGP_amd64_darwin)
+#  if defined(VGP_amd64_darwin) || defined(VGP_amd64_linux)
    vex_abiinfo.guest_amd64_assume_gs_is_0x60  = True;
 #  endif
 #  if defined(VGP_ppc32_linux)
Index: coregrind/m_syswrap/syswrap-amd64-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-amd64-linux.c	(revision 13279)
+++ coregrind/m_syswrap/syswrap-amd64-linux.c	(working copy)
@@ -564,6 +564,16 @@
       *(unsigned long *)ARG2 = tst->arch.vex.guest_FS_ZERO;
       POST_MEM_WRITE(ARG2, sizeof(unsigned long));
    }
+   else if (ARG1 == VKI_ARCH_SET_GS) {
+      tst = VG_(get_ThreadState)(tid);
+      tst->arch.vex.guest_GS_0x60 = ARG2;
+   }
+   else if (ARG1 == VKI_ARCH_GET_GS) {
+      PRE_MEM_WRITE("arch_prctl(addr)", ARG2, sizeof(unsigned long));
+      tst = VG_(get_ThreadState)(tid);
+      *(unsigned long *)ARG2 = tst->arch.vex.guest_GS_0x60;
+      POST_MEM_WRITE(ARG2, sizeof(unsigned long));
+   }
    else {
       VG_(core_panic)("Unsupported arch_prtctl option");
    }




More information about the wine-devel mailing list