bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 1 | #include <stdint.h> |
| 2 | #include <stdio.h> |
| 3 | #include "valgrind.h" |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 4 | #include "drd.h" |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 5 | #include "pub_tool_redir.h" |
| 6 | |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 7 | /* |
| 8 | * On Mac OS X shared library functions are lazily bound. The binding mechanism |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 9 | * uses self-modifying code. Intercept fastBindLazySymbol() in order to suppress |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 10 | * 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). |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 14 | * 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] | 15 | */ |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 16 | void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm) |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 17 | (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset); |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 18 | void* VG_WRAP_FUNCTION_ZZ(dyld, ZuZZN4dyld18fastBindLazySymbolEPP11ImageLoaderm) |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 19 | (void** imageLoaderCache, uintptr_t lazyBindingInfoOffset) |
| 20 | { |
| 21 | void* res; |
| 22 | OrigFn fn; |
| 23 | |
| 24 | VALGRIND_GET_ORIG_FN(fn); |
| 25 | |
bart | ab8f93d | 2011-03-06 16:33:08 +0000 | [diff] [blame^] | 26 | DRD_IGNORE_VAR(*imageLoaderCache); |
| 27 | |
bart | 6de4f41 | 2011-03-06 12:39:12 +0000 | [diff] [blame] | 28 | CALL_FN_W_WW(res, fn, imageLoaderCache, lazyBindingInfoOffset); |
| 29 | |
| 30 | return res; |
| 31 | } |