]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/drd/drd_darwin_intercepts.c
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / drd / drd_darwin_intercepts.c
1 /* -*- mode: C; c-basic-offset: 3; indent-tabs-mode: nil; -*- */
2 /*
3   This file is part of drd, a thread error detector.
4
5   Copyright (C) 2006-2011 Bart Van Assche <bvanassche@acm.org>.
6
7   This program is free software; you can redistribute it and/or
8   modify it under the terms of the GNU General Public License as
9   published by the Free Software Foundation; either version 2 of the
10   License, or (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20   02111-1307, USA.
21
22   The GNU General Public License is contained in the file COPYING.
23 */
24
25 #include <stdint.h>
26 #include <stdio.h>
27 #include "valgrind.h"
28 #include "drd.h"
29 #include "pub_tool_redir.h"
30
31 /*
32  * On Mac OS X shared library functions are lazily bound. The binding mechanism
33  * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress
34  * the data accesses involved in this mechanism.
35  *
36  * 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).
37  * See also the dyld_stub_binder() source code (http://www.opensource.apple.com/source/dyld/dyld-132.13/src/dyld_stub_binder.s).
38  * See also the dyld::fastBindLazySymbol() source code (http://opensource.apple.com/source/dyld/dyld-132.13/src/dyld.cpp).
39  */
40 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
41      (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset);
42 void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm)
43      (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset)
44 {
45    void* res;
46    OrigFn fn;
47   
48    VALGRIND_GET_ORIG_FN(fn);
49
50    ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN();
51    CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset);
52    ANNOTATE_IGNORE_READS_AND_WRITES_END();
53
54    return res;
55 }