drd/tests/tsan_unittest: Avoid that this test reads from uninitialized memory
[valgrind.git] / drd / drd_darwin_intercepts.c
blobf70adc38238bcf73b4effbe34819e8e2aa6c28fc
1 /*
2 This file is part of drd, a thread error detector.
4 Copyright (C) 2006-2017 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, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
21 The GNU General Public License is contained in the file COPYING.
24 #include <stdint.h>
25 #include <stdio.h>
26 #include "pub_tool_clreq.h"
27 #include "drd.h"
28 #include "pub_tool_redir.h"
31 * On Mac OS X shared library functions are lazily bound. The binding mechanism
32 * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress
33 * the data accesses involved in this mechanism.
35 * 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).
36 * See also the dyld_stub_binder() source code (http://www.opensource.apple.com/source/dyld/dyld-132.13/src/dyld_stub_binder.s).
37 * See also the dyld::fastBindLazySymbol() source code (http://opensource.apple.com/source/dyld/dyld-132.13/src/dyld.cpp).
39 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
40 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset);
41 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
42 (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset)
44 void* res;
45 OrigFn fn;
47 VALGRIND_GET_ORIG_FN(fn);
49 ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
50 CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset);
51 ANNOTATE_IGNORE_READS_AND_WRITES_END();
53 return res;