-> 3.17.0.RC2
[valgrind.git] / drd / drd_darwin_intercepts.c
blob9b082173a1657bed9322d2887249bfeb668be3e3
1 /*
2 This file is part of drd, a thread error detector.
4 Copyright (C) 2006-2020 Bart Van Assche <bvanassche@acm.org>.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
19 The GNU General Public License is contained in the file COPYING.
22 #include <stdint.h>
23 #include <stdio.h>
24 #include "pub_tool_clreq.h"
25 #include "drd.h"
26 #include "pub_tool_redir.h"
29 * On Mac OS X shared library functions are lazily bound. The binding mechanism
30 * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress
31 * the data accesses involved in this mechanism.
33 * 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).
34 * See also the dyld_stub_binder() source code (http://www.opensource.apple.com/source/dyld/dyld-132.13/src/dyld_stub_binder.s).
35 * See also the dyld::fastBindLazySymbol() source code (http://opensource.apple.com/source/dyld/dyld-132.13/src/dyld.cpp).
37 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
38 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset);
39 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
40 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset)
42 void* res;
43 OrigFn fn;
45 VALGRIND_GET_ORIG_FN(fn);
47 ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
48 CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset);
49 ANNOTATE_IGNORE_READS_AND_WRITES_END();
51 return res;