]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 337094 ifunc wrapper is broken on ppc64.
authorMark Wielaard <mark@klomp.org>
Tue, 15 Jul 2014 15:07:01 +0000 (15:07 +0000)
committerMark Wielaard <mark@klomp.org>
Tue, 15 Jul 2014 15:07:01 +0000 (15:07 +0000)
ppc64 uses function descriptors, so we need to get the actual function
entry address for the VG_USERREQ__ADD_IFUNC_TARGET client request, but
we need to return the function descriptor itself from the ifunc_wrapper.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14163

NEWS
coregrind/vg_preloaded.c

diff --git a/NEWS b/NEWS
index 1bc95a9b17a6602f4b358d3e82ec7a9a43d43fb2..16415ab945f2e15acd45eccd0543b3d1f4cd0c99 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -179,6 +179,7 @@ where XXXXXX is the bug number as listed below.
 335496  arm64: sbc/abc instructions are not implemented
 336772  Make moans about unknown ioctls more informative
 336957  Add a section about the Solaris/illumos port on the webpage
+337094  ifunc wrapper is broken on ppc64
 337285  fcntl commands F_OFD_SETLK, F_OFD_SETLKW, and F_OFD_GETLK not supported
 n-i-bz  Fix KVM_CREATE_IRQCHIP ioctl handling
 n-i-bz  s390x: Fix memory corruption for multithreaded applications
index dba32140884e03de5e8463bb9858477ab657888a..17bfb7283314657eb3f63c1350f484d428408410 100644 (file)
@@ -77,17 +77,28 @@ void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void)
 {
     OrigFn fn;
     Addr result = 0;
+    Addr fnentry;
 
     /* Call the original indirect function and get it's result */
     VALGRIND_GET_ORIG_FN(fn);
     CALL_FN_W_v(result, fn);
 
+#if defined(VGP_ppc64_linux)
+   /* ppc64 uses function descriptors, so get the actual function entry
+      address for the client request, but return the function descriptor
+      from this function. */
+    UWord *descr = (UWord*)result;
+    fnentry = (void*)(descr[0]);
+#else
+    fnentry = result;
+#endif
+
     /* Ask the valgrind core running on the real CPU (as opposed to this
        code which runs on the emulated CPU) to update the redirection that
        led to this function. This client request eventually gives control to
        the function VG_(redir_add_ifunc_target) in m_redir.c  */
     VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__ADD_IFUNC_TARGET,
-                                    fn.nraddr, result, 0, 0, 0);
+                                    fn.nraddr, fnentry, 0, 0, 0);
     return (void*)result;
 }