From 03eb8f43a7974195000bf82104a37a71e0fd857a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 15 Jul 2014 15:07:01 +0000 Subject: [PATCH] Bug 337094 ifunc wrapper is broken on ppc64. 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 | 1 + coregrind/vg_preloaded.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1bc95a9b1..16415ab94 100644 --- 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 diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c index dba321408..17bfb7283 100644 --- a/coregrind/vg_preloaded.c +++ b/coregrind/vg_preloaded.c @@ -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; } -- 2.11.4.GIT