blob: 67fd3e24536e73345341f1e70f26c6ea57da77e5 [file] [log] [blame]
bart6de4f412011-03-06 12:39:12 +00001#include <stdint.h>
2#include <stdio.h>
3#include "valgrind.h"
bartab8f93d2011-03-06 16:33:08 +00004#include "drd.h"
bart6de4f412011-03-06 12:39:12 +00005#include "pub_tool_redir.h"
6
bart6de4f412011-03-06 12:39:12 +00007/*
8 * On Mac OS X shared library functions are lazily bound. The binding mechanism
bartab8f93d2011-03-06 16:33:08 +00009 * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress
bart6de4f412011-03-06 12:39:12 +000010 * the data accesses involved in this mechanism.
11 *
12 * See also the Mac OS X ABI Dynamic Loader Reference (http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/c/func/dyld_stub_binding_helper).
13 * See also the dyld_stub_binder() source code (http://www.opensource.apple.com/source/dyld/dyld-132.13/src/dyld_stub_binder.s).
bartab8f93d2011-03-06 16:33:08 +000014 * See also the dyld::fastBindLazySymbol() source code (http://opensource.apple.com/source/dyld/dyld-132.13/src/dyld.cpp).
bart6de4f412011-03-06 12:39:12 +000015 */
bartab8f93d2011-03-06 16:33:08 +000016void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
bart6de4f412011-03-06 12:39:12 +000017 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset);
bartab8f93d2011-03-06 16:33:08 +000018void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
bart6de4f412011-03-06 12:39:12 +000019 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset)
20{
21 void* res;
22 OrigFn fn;
23
24 VALGRIND_GET_ORIG_FN(fn);
25
bartab8f93d2011-03-06 16:33:08 +000026 DRD_IGNORE_VAR(*imageLoaderCache);
27
bart6de4f412011-03-06 12:39:12 +000028 CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset);
29
30 return res;
31}