[llvm-commits] [compiler-rt] r161168 - in /compiler-rt/trunk/lib/interception: interception.h interception_linux.cc interception_linux.h interception_mac.cc interception_mac.h
Alexey Samsonov
samsonov at google.com
Thu Aug 2 04:19:13 PDT 2012
Author: samsonov
Date: Thu Aug 2 06:19:13 2012
New Revision: 161168
URL: http://llvm.org/viewvc/llvm-project?rev=161168&view=rev
Log:
[Sanitizer] Workaround for a compiler warning - ISO C++ forbids casting pointer-to-function to pointer-to-object, so we use cast via integral type
Modified:
compiler-rt/trunk/lib/interception/interception.h
compiler-rt/trunk/lib/interception/interception_linux.cc
compiler-rt/trunk/lib/interception/interception_linux.h
compiler-rt/trunk/lib/interception/interception_mac.cc
compiler-rt/trunk/lib/interception/interception_mac.h
Modified: compiler-rt/trunk/lib/interception/interception.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception.h?rev=161168&r1=161167&r2=161168&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception.h (original)
+++ compiler-rt/trunk/lib/interception/interception.h Thu Aug 2 06:19:13 2012
@@ -148,6 +148,15 @@
INTERCEPTOR_EX(ret_type, __stdcall, func, __VA_ARGS__)
#endif
+// ISO C++ forbids casting between pointer-to-function and pointer-to-object,
+// so we use casting via an integral type __interception::uptr,
+// assuming that system is POSIX-compliant. Using other hacks seem
+// challenging, as we don't even pass function type to
+// INTERCEPT_FUNCTION macro, only its name.
+namespace __interception {
+typedef unsigned long uptr; // NOLINT
+} // namespace __interception
+
#define INCLUDED_FROM_INTERCEPTION_LIB
#if defined(__linux__)
Modified: compiler-rt/trunk/lib/interception/interception_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.cc?rev=161168&r1=161167&r2=161168&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_linux.cc (original)
+++ compiler-rt/trunk/lib/interception/interception_linux.cc Thu Aug 2 06:19:13 2012
@@ -13,14 +13,15 @@
//===----------------------------------------------------------------------===//
#ifdef __linux__
+#include "interception.h"
#include <stddef.h> // for NULL
#include <dlfcn.h> // for dlsym
namespace __interception {
-bool GetRealFunctionAddress(const char *func_name, void **func_addr,
- void *real, void *wrapper) {
- *func_addr = dlsym(RTLD_NEXT, func_name);
+bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+ uptr real, uptr wrapper) {
+ *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
return real == wrapper;
}
} // namespace __interception
Modified: compiler-rt/trunk/lib/interception/interception_linux.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=161168&r1=161167&r2=161168&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_linux.h (original)
+++ compiler-rt/trunk/lib/interception/interception_linux.h Thu Aug 2 06:19:13 2012
@@ -23,13 +23,15 @@
namespace __interception {
// returns true if a function with the given name was found.
-bool GetRealFunctionAddress(const char *func_name, void **func_addr,
- void *real, void *wrapper);
+bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
+ uptr real, uptr wrapper);
} // namespace __interception
#define INTERCEPT_FUNCTION_LINUX(func) \
- ::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func), \
- (void*)&(func), (void*)&WRAP(func))
+ ::__interception::GetRealFunctionAddress( \
+ #func, (::__interception::uptr*)&REAL(func), \
+ (::__interception::uptr)&(func), \
+ (::__interception::uptr)&WRAP(func))
#endif // INTERCEPTION_LINUX_H
#endif // __linux__
Modified: compiler-rt/trunk/lib/interception/interception_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_mac.cc?rev=161168&r1=161167&r2=161168&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_mac.cc (original)
+++ compiler-rt/trunk/lib/interception/interception_mac.cc Thu Aug 2 06:19:13 2012
@@ -14,19 +14,17 @@
#ifdef __APPLE__
-#define INCLUDED_FROM_INTERCEPTION_LIB
-#include "interception_mac.h"
-#undef INCLUDED_FROM_INTERCEPTION_LIB
+#include "interception.h"
#include "mach_override/mach_override.h"
namespace __interception {
-bool OverrideFunction(void *old_func, void *new_func, void **orig_old_func) {
- *orig_old_func = NULL;
- int res = __asan_mach_override_ptr_custom(old_func, new_func,
- orig_old_func,
+bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func) {
+ *orig_old_func = 0;
+ int res = __asan_mach_override_ptr_custom((void*)old_func, (void*)new_func,
+ (void**)orig_old_func,
__interception_allocate_island,
__interception_deallocate_island);
- return (res == 0) && (*orig_old_func != NULL);
+ return (res == 0) && (*orig_old_func != 0);
}
} // namespace __interception
Modified: compiler-rt/trunk/lib/interception/interception_mac.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_mac.h?rev=161168&r1=161167&r2=161168&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_mac.h (original)
+++ compiler-rt/trunk/lib/interception/interception_mac.h Thu Aug 2 06:19:13 2012
@@ -35,12 +35,14 @@
namespace __interception {
// returns true if the old function existed.
-bool OverrideFunction(void *old_func, void *new_func, void **orig_old_func);
+bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
} // namespace __interception
# define OVERRIDE_FUNCTION_MAC(old_func, new_func) \
- ::__interception::OverrideFunction((void*)old_func, (void*)new_func, \
- (void**)&REAL(old_func))
+ ::__interception::OverrideFunction( \
+ (::__interception::uptr)old_func, \
+ (::__interception::uptr)new_func, \
+ (::__interception::uptr*)&REAL(old_func))
# define INTERCEPT_FUNCTION_MAC(func) OVERRIDE_FUNCTION_MAC(func, WRAP(func))
#endif // INTERCEPTION_MAC_H
More information about the llvm-commits
mailing list