bart | e8653ac | 2011-03-07 18:00:26 +0000 | [diff] [blame^] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ |
| 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 | |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 25 | #include <stdint.h> |
| 26 | #include <stdio.h> |
| 27 | #include "valgrind.h" |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame] | 28 | #include "drd.h" |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 29 | #include "pub_tool_redir.h" |
| 30 | |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 31 | /* |
| 32 | * On Mac OS X shared library functions are lazily bound. The binding mechanism |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame] | 33 | * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 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). |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame] | 38 | * See also the dyld::fastBindLazySymbol() source code (http://opensource.apple.com/source/dyld/dyld-132.13/src/dyld.cpp). |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 39 | */ |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame] | 40 | void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm) |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 41 | (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset); |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame] | 42 | void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm) |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 43 | (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset) |
| 44 | { |
bart | e8653ac | 2011-03-07 18:00:26 +0000 | [diff] [blame^] | 45 | void* res; |
| 46 | OrigFn fn; |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 47 | |
bart | e8653ac | 2011-03-07 18:00:26 +0000 | [diff] [blame^] | 48 | VALGRIND_GET_ORIG_FN(fn); |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 49 | |
bart | e8653ac | 2011-03-07 18:00:26 +0000 | [diff] [blame^] | 50 | ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN(); |
| 51 | CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset); |
| 52 | ANNOTATE_IGNORE_READS_AND_WRITES_END(); |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 53 | |
bart | e8653ac | 2011-03-07 18:00:26 +0000 | [diff] [blame^] | 54 | return res; |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 55 | } |