On Thu, May 24, 2012 at 10:18 PM, Meador Inge <span dir="ltr"><<a href="mailto:meadori@gmail.com" target="_blank">meadori@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This commit broke the build.  See inline.<br>
<br>
On Thu, May 24, 2012 at 8:54 AM, Dmitry Vyukov <<a href="mailto:dvyukov@google.com">dvyukov@google.com</a>> wrote:<br>
> Author: dvyukov<br>
> Date: Thu May 24 08:54:31 2012<br>
> New Revision: 157388<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=157388&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=157388&view=rev</a><br>
> Log:<br>
> asan/tsan: weak interceptors<br>
> The idea isthat asan/tsan can survive if user intercepts the same functions. At the same time user has an ability to call back into asan/tsan runtime. See the following tests for examples:<br>
> asan/output_tests/interception_failure_test-linux.cc<br>
> asan/output_tests/interception_test-linux.cc<br>
> asan/output_tests/interception_malloc_test-linux.cc<br>
><br>
><br>
> Added:<br>
>    compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc   (with props)<br>
>    compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc   (with props)<br>
>    compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc   (with props)<br>
> Modified:<br>
>    compiler-rt/trunk/lib/asan/asan_interceptors.cc<br>
>    compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc<br>
>    compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc<br>
>    compiler-rt/trunk/lib/asan/output_tests/test_output.sh<br>
>    compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc<br>
>    compiler-rt/trunk/lib/interception/interception.h<br>
>    compiler-rt/trunk/lib/interception/interception_linux.cc<br>
>    compiler-rt/trunk/lib/interception/interception_linux.h<br>
>    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc<br>
><br>
> Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)<br>
> +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Thu May 24 08:54:31 2012<br>
> @@ -743,6 +743,11 @@<br>
>  }<br>
>  #endif  // ASAN_INTERCEPT_ATOLL_AND_STRTOLL<br>
><br>
> +#define ASAN_INTERCEPT_FUNC(name) do { \<br>
> +      if (!INTERCEPT_FUNCTION(name) && FLAG_v > 0) \<br>
> +        Report("AddressSanitizer: failed to intercept '" #name "'\n"); \<br>
> +    } while (0)<br>
> +<br>
>  #if defined(_WIN32)<br>
>  INTERCEPTOR_WINAPI(DWORD, CreateThread,<br>
>                    void* security, size_t stack_size,<br>
> @@ -758,7 +763,7 @@<br>
><br>
>  namespace __asan {<br>
>  void InitializeWindowsInterceptors() {<br>
> -  CHECK(INTERCEPT_FUNCTION(CreateThread));<br>
> +  ASAN_INTERCEPT_FUNC(CreateThread);<br>
>  }<br>
><br>
>  }  // namespace __asan<br>
> @@ -771,65 +776,65 @@<br>
>   CHECK(was_called_once == false);<br>
>   was_called_once = true;<br>
>   // Intercept mem* functions.<br>
> -  CHECK(INTERCEPT_FUNCTION(memcmp));<br>
> -  CHECK(INTERCEPT_FUNCTION(memmove));<br>
> -  CHECK(INTERCEPT_FUNCTION(memset));<br>
> +  ASAN_INTERCEPT_FUNC(memcmp);<br>
> +  ASAN_INTERCEPT_FUNC(memmove);<br>
> +  ASAN_INTERCEPT_FUNC(memset);<br>
>   if (PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE) {<br>
> -    CHECK(INTERCEPT_FUNCTION(memcpy));<br>
> +    ASAN_INTERCEPT_FUNC(memcpy);<br>
>   } else {<br>
>     REAL(memcpy) = REAL(memmove);<br>
>   }<br>
><br>
>   // Intercept str* functions.<br>
> -  CHECK(INTERCEPT_FUNCTION(strcat));  // NOLINT<br>
> -  CHECK(INTERCEPT_FUNCTION(strchr));<br>
> -  CHECK(INTERCEPT_FUNCTION(strcmp));<br>
> -  CHECK(INTERCEPT_FUNCTION(strcpy));  // NOLINT<br>
> -  CHECK(INTERCEPT_FUNCTION(strlen));<br>
> -  CHECK(INTERCEPT_FUNCTION(strncmp));<br>
> -  CHECK(INTERCEPT_FUNCTION(strncpy));<br>
> +  ASAN_INTERCEPT_FUNC(strcat);  // NOLINT<br>
> +  ASAN_INTERCEPT_FUNC(strchr);<br>
> +  ASAN_INTERCEPT_FUNC(strcmp);<br>
> +  ASAN_INTERCEPT_FUNC(strcpy);  // NOLINT<br>
> +  ASAN_INTERCEPT_FUNC(strlen);<br>
> +  ASAN_INTERCEPT_FUNC(strncmp);<br>
> +  ASAN_INTERCEPT_FUNC(strncpy);<br>
>  #if !defined(_WIN32)<br>
> -  CHECK(INTERCEPT_FUNCTION(strcasecmp));<br>
> -  CHECK(INTERCEPT_FUNCTION(strdup));<br>
> -  CHECK(INTERCEPT_FUNCTION(strncasecmp));<br>
> +  ASAN_INTERCEPT_FUNC(strcasecmp);<br>
> +  ASAN_INTERCEPT_FUNC(strdup);<br>
> +  ASAN_INTERCEPT_FUNC(strncasecmp);<br>
>  # ifndef __APPLE__<br>
> -  CHECK(INTERCEPT_FUNCTION(index));<br>
> +  ASAN_INTERCEPT_FUNC(index);<br>
>  # else<br>
> -  CHECK(OVERRIDE_FUNCTION(index, WRAP(strchr)));<br>
> +  CHECK(OVERRIDE_FUNCTION(index, WRAP(strchr));<br>
<br>
A right parenthesis was dropped here.  I added it back to unwedge the build.<br>
Please make the correct fix if this line was meant to be changed to<br>
something else.<br></blockquote><div><br></div><div>Ouch!</div><div>Thanks for fixing it!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>  # endif<br>
>  #endif<br>
>  #if ASAN_INTERCEPT_STRNLEN<br>
> -  CHECK(INTERCEPT_FUNCTION(strnlen));<br>
> +  ASAN_INTERCEPT_FUNC(strnlen);<br>
>  #endif<br>
><br>
> -  CHECK(INTERCEPT_FUNCTION(atoi));<br>
> -  CHECK(INTERCEPT_FUNCTION(atol));<br>
> -  CHECK(INTERCEPT_FUNCTION(strtol));<br>
> +  ASAN_INTERCEPT_FUNC(atoi);<br>
> +  ASAN_INTERCEPT_FUNC(atol);<br>
> +  ASAN_INTERCEPT_FUNC(strtol);<br>
>  #if ASAN_INTERCEPT_ATOLL_AND_STRTOLL<br>
> -  CHECK(INTERCEPT_FUNCTION(atoll));<br>
> -  CHECK(INTERCEPT_FUNCTION(strtoll));<br>
> +  ASAN_INTERCEPT_FUNC(atoll);<br>
> +  ASAN_INTERCEPT_FUNC(strtoll);<br>
>  #endif<br>
><br>
>   // Intecept signal- and jump-related functions.<br>
> -  CHECK(INTERCEPT_FUNCTION(longjmp));<br>
> +  ASAN_INTERCEPT_FUNC(longjmp);<br>
>  #if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION<br>
> -  CHECK(INTERCEPT_FUNCTION(sigaction));<br>
> -  CHECK(INTERCEPT_FUNCTION(signal));<br>
> +  ASAN_INTERCEPT_FUNC(sigaction);<br>
> +  ASAN_INTERCEPT_FUNC(signal);<br>
>  #endif<br>
><br>
>  #if !defined(_WIN32)<br>
> -  CHECK(INTERCEPT_FUNCTION(_longjmp));<br>
> +  ASAN_INTERCEPT_FUNC(_longjmp);<br>
>   INTERCEPT_FUNCTION(__cxa_throw);<br>
>  # if !defined(__APPLE__)<br>
>   // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it<br>
>   // there.<br>
> -  CHECK(INTERCEPT_FUNCTION(siglongjmp));<br>
> +  ASAN_INTERCEPT_FUNC(siglongjmp);<br>
>  # endif<br>
>  #endif<br>
><br>
>   // Intercept threading-related functions<br>
>  #if !defined(_WIN32)<br>
> -  CHECK(INTERCEPT_FUNCTION(pthread_create));<br>
> +  ASAN_INTERCEPT_FUNC(pthread_create);<br>
>  #endif<br>
><br>
>   // Some Windows-specific interceptors.<br>
><br>
> Modified: compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc (original)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc Thu May 24 08:54:31 2012<br>
> @@ -13,7 +13,7 @@<br>
>  // Check-Common: {{0x.* is located 0 bytes to the right of 10-byte region}}<br>
>  // Check-Common: {{allocated by thread T0 here:}}<br>
><br>
> -// Check-Linux: {{    #0 0x.* in malloc}}<br>
> +// Check-Linux: {{    #0 0x.* in __xsan_malloc}}<br>
>  // Check-Linux: {{    #1 0x.* in main .*heap-overflow.cc:[45]}}<br>
><br>
>  // Check-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
><br>
> Added: compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc?rev=157388&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc?rev=157388&view=auto</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc (added)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc Thu May 24 08:54:31 2012<br>
> @@ -0,0 +1,17 @@<br>
> +#include <stdlib.h><br>
> +#include <stdio.h><br>
> +<br>
> +extern "C" long strtol(const char *nptr, char **endptr, int base) {<br>
> +  fprintf(stderr, "my_strtol_interceptor\n");<br>
> +  return 0;<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  char *x = (char*)malloc(10 * sizeof(char));<br>
> +  free(x);<br>
> +  return (int)strtol(x, 0, 10);<br>
> +}<br>
> +<br>
> +// Check-Common: my_strtol_interceptor<br>
> +// CHECK-NOT: heap-use-after-free<br>
> +<br>
><br>
> Propchange: compiler-rt/trunk/lib/asan/output_tests/interception_failure_test-linux.cc<br>
> ------------------------------------------------------------------------------<br>
>    svn:eol-style = LF<br>
><br>
> Added: compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc?rev=157388&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc?rev=157388&view=auto</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc (added)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc Thu May 24 08:54:31 2012<br>
> @@ -0,0 +1,19 @@<br>
> +#include <stdlib.h><br>
> +#include <stdio.h><br>
> +#include <unistd.h><br>
> +<br>
> +extern "C" void *__xsan_malloc(size_t size);<br>
> +extern "C" void *malloc(size_t size) {<br>
> +  write(2, "malloc call\n", sizeof("malloc call\n") - 1);<br>
> +  return __xsan_malloc(size);<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  char *x = (char*)malloc(10 * sizeof(char));<br>
> +  free(x);<br>
> +  return (int)strtol(x, 0, 10);<br>
> +}<br>
> +<br>
> +// Check-Common: malloc call<br>
> +// Check-Common: heap-use-after-free<br>
> +<br>
><br>
> Propchange: compiler-rt/trunk/lib/asan/output_tests/interception_malloc_test-linux.cc<br>
> ------------------------------------------------------------------------------<br>
>    svn:eol-style = LF<br>
><br>
> Added: compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc?rev=157388&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc?rev=157388&view=auto</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc (added)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc Thu May 24 08:54:31 2012<br>
> @@ -0,0 +1,18 @@<br>
> +#include <stdlib.h><br>
> +#include <stdio.h><br>
> +<br>
> +extern "C" long __xsan_strtol(const char *nptr, char **endptr, int base);<br>
> +extern "C" long strtol(const char *nptr, char **endptr, int base) {<br>
> +  fprintf(stderr, "my_strtol_interceptor\n");<br>
> +  return __xsan_strtol(nptr, endptr, base);<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  char *x = (char*)malloc(10 * sizeof(char));<br>
> +  free(x);<br>
> +  return (int)strtol(x, 0, 10);<br>
> +}<br>
> +<br>
> +// Check-Common: my_strtol_interceptor<br>
> +// Check-Common: heap-use-after-free<br>
> +<br>
><br>
> Propchange: compiler-rt/trunk/lib/asan/output_tests/interception_test-linux.cc<br>
> ------------------------------------------------------------------------------<br>
>    svn:eol-style = LF<br>
><br>
> Modified: compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc (original)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc Thu May 24 08:54:31 2012<br>
> @@ -9,13 +9,13 @@<br>
>  }<br>
><br>
>  // Check-Common: {{WRITE of size 1 at 0x.* thread T0}}<br>
> -// Check-Linux: {{    #0 0x.* in strncpy}}<br>
> +// Check-Linux: {{    #0 0x.* in __xsan_strncpy}}<br>
>  // Check-Darwin: {{    #0 0x.* in wrap_strncpy}}<br>
>  // Check-Common: {{    #1 0x.* in main .*strncpy-overflow.cc:[78]}}<br>
>  // Check-Common: {{0x.* is located 0 bytes to the right of 9-byte region}}<br>
>  // Check-Common: {{allocated by thread T0 here:}}<br>
><br>
> -// Check-Linux: {{    #0 0x.* in malloc}}<br>
> +// Check-Linux: {{    #0 0x.* in __xsan_malloc}}<br>
>  // Check-Linux: {{    #1 0x.* in main .*strncpy-overflow.cc:6}}<br>
><br>
>  // Check-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
><br>
> Modified: compiler-rt/trunk/lib/asan/output_tests/test_output.sh<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/test_output.sh?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/test_output.sh?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/test_output.sh (original)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/test_output.sh Thu May 24 08:54:31 2012<br>
> @@ -14,7 +14,7 @@<br>
>   ./$1 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt > $TMP_ASAN_REPORT<br>
>  }<br>
><br>
> -# check_program exe_file source_file check_prefix<br>
> +# check_program exe_file source_file check_prefixf<br>
>  check_program() {<br>
>   run_program $1<br>
>   $FILE_CHECK $2 --check-prefix=$3 < $TMP_ASAN_REPORT<br>
> @@ -43,10 +43,14 @@<br>
>   for b in 32 64; do<br>
>     for O in 0 1 2 3; do<br>
>       c=`basename $t .cc`<br>
> -      if [[ "$c" == *"-so" ]]<br>
> -      then<br>
> +      if [[ "$c" == *"-so" ]]; then<br>
>         continue<br>
>       fi<br>
> +      if [[ "$c" == *"-linux" ]]; then<br>
> +        if [[ "$OS" != "Linux" ]]; then<br>
> +          continue<br>
> +        fi<br>
> +      fi<br>
>       c_so=$c-so<br>
>       exe=$c.$b.O$O<br>
>       so=$c.$b.O$O-so.so<br>
><br>
> Modified: compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc (original)<br>
> +++ compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc Thu May 24 08:54:31 2012<br>
> @@ -12,7 +12,7 @@<br>
>  // Check-Common: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}<br>
>  // Check-Common: {{freed by thread T0 here:}}<br>
><br>
> -// Check-Linux: {{    #0 0x.* in free}}<br>
> +// Check-Linux: {{    #0 0x.* in __xsan_free}}<br>
>  // Check-Linux: {{    #1 0x.* in main .*use-after-free.cc:[45]}}<br>
><br>
>  // Check-Darwin: {{    #0 0x.* in .*mz_free.*}}<br>
> @@ -22,7 +22,7 @@<br>
><br>
>  // Check-Common: {{previously allocated by thread T0 here:}}<br>
><br>
> -// Check-Linux: {{    #0 0x.* in malloc}}<br>
> +// Check-Linux: {{    #0 0x.* in __xsan_malloc}}<br>
>  // Check-Linux: {{    #1 0x.* in main .*use-after-free.cc:3}}<br>
><br>
>  // Check-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
><br>
> Modified: compiler-rt/trunk/lib/interception/interception.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception.h?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception.h?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/interception/interception.h (original)<br>
> +++ compiler-rt/trunk/lib/interception/interception.h Thu May 24 08:54:31 2012<br>
> @@ -61,20 +61,26 @@<br>
>  //           source file (to define a pointer to overriden function).<br>
><br>
>  // How it works:<br>
> -// To replace weak system functions on Linux we just need to declare functions<br>
> +// To replace system functions on Linux we just need to declare functions<br>
>  // with same names in our library and then obtain the real function pointers<br>
> -// using dlsym(). This is not so on Mac OS, where the two-level namespace makes<br>
> +// using dlsym().<br>
> +// There is one complication. A user may also intercept some of the functions<br>
> +// we intercept. To resolve this we declare our interceptors with __xsan_<br>
> +// prefix, and then make actual interceptors weak aliases to __xsan_<br>
> +// functions.<br>
> +// This is not so on Mac OS, where the two-level namespace makes<br>
>  // our replacement functions invisible to other libraries. This may be overcomed<br>
>  // using the DYLD_FORCE_FLAT_NAMESPACE, but some errors loading the shared<br>
> -// libraries in Chromium were noticed when doing so.<br>
> -// Instead we use mach_override, a handy framework for patching functions at<br>
> -// runtime. To avoid possible name clashes, our replacement functions have<br>
> +// libraries in Chromium were noticed when doing so. Instead we use<br>
> +// mach_override, a handy framework for patching functions at runtime.<br>
> +// To avoid possible name clashes, our replacement functions have<br>
>  // the "wrap_" prefix on Mac.<br>
><br>
>  #if defined(__APPLE__)<br>
>  # define WRAP(x) wrap_##x<br>
>  # define WRAPPER_NAME(x) "wrap_"#x<br>
>  # define INTERCEPTOR_ATTRIBUTE<br>
> +# define DECLARE_WRAPPER(ret_type, convention, func, ...)<br>
>  #elif defined(_WIN32)<br>
>  # if defined(_DLL)  // DLL CRT<br>
>  #  define WRAP(x) x<br>
> @@ -85,10 +91,14 @@<br>
>  #  define WRAPPER_NAME(x) "wrap_"#x<br>
>  #  define INTERCEPTOR_ATTRIBUTE<br>
>  # endif<br>
> +# define DECLARE_WRAPPER(ret_type, convention, func, ...)<br>
>  #else<br>
> -# define WRAP(x) x<br>
> -# define WRAPPER_NAME(x) #x<br>
> +# define WRAP(x) __xsan_ ## x<br>
> +# define WRAPPER_NAME(x) "__xsan_" #x<br>
>  # define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))<br>
> +# define DECLARE_WRAPPER(ret_type, convention, func, ...) \<br>
> +    extern "C" ret_type convention func(__VA_ARGS__) \<br>
> +    __attribute__((weak, alias("__xsan_" #func), visibility("default")))<br>
>  #endif<br>
><br>
>  #define PTR_TO_REAL(x) real_##x<br>
> @@ -125,6 +135,7 @@<br>
><br>
>  #define INTERCEPTOR_EX(ret_type, convention, func, ...) \<br>
>   DEFINE_REAL_EX(ret_type, convention, func, __VA_ARGS__); \<br>
> +  DECLARE_WRAPPER(ret_type, convention, func, __VA_ARGS__); \<br>
>   extern "C" \<br>
>   INTERCEPTOR_ATTRIBUTE \<br>
>   ret_type convention WRAP(func)(__VA_ARGS__)<br>
><br>
> Modified: compiler-rt/trunk/lib/interception/interception_linux.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/interception/interception_linux.cc (original)<br>
> +++ compiler-rt/trunk/lib/interception/interception_linux.cc Thu May 24 08:54:31 2012<br>
> @@ -18,9 +18,10 @@<br>
>  #include <dlfcn.h>   // for dlsym<br>
><br>
>  namespace __interception {<br>
> -bool GetRealFunctionAddress(const char *func_name, void **func_addr) {<br>
> +bool GetRealFunctionAddress(const char *func_name, void **func_addr,<br>
> +    void *real, void *wrapper) {<br>
>   *func_addr = dlsym(RTLD_NEXT, func_name);<br>
> -  return (*func_addr != NULL);<br>
> +  return real == wrapper;<br>
>  }<br>
>  }  // namespace __interception<br>
><br>
><br>
> Modified: compiler-rt/trunk/lib/interception/interception_linux.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/interception/interception_linux.h (original)<br>
> +++ compiler-rt/trunk/lib/interception/interception_linux.h Thu May 24 08:54:31 2012<br>
> @@ -23,11 +23,13 @@<br>
><br>
>  namespace __interception {<br>
>  // returns true if a function with the given name was found.<br>
> -bool GetRealFunctionAddress(const char *func_name, void **func_addr);<br>
> +bool GetRealFunctionAddress(const char *func_name, void **func_addr,<br>
> +    void *real, void *wrapper);<br>
>  }  // namespace __interception<br>
><br>
>  #define INTERCEPT_FUNCTION_LINUX(func) \<br>
> -    ::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func))<br>
> +    ::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func), \<br>
> +    (void*)&(func), (void*)&WRAP(func))<br>
><br>
>  #endif  // INTERCEPTION_LINUX_H<br>
>  #endif  // __linux__<br>
><br>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=157388&r1=157387&r2=157388&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=157388&r1=157387&r2=157388&view=diff</a><br>

> ==============================================================================<br>
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)<br>
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Thu May 24 08:54:31 2012<br>
> @@ -32,7 +32,7 @@<br>
>  static void StackStripMain(ReportStack *stack) {<br>
>   ReportStack *last_frame = 0;<br>
>   ReportStack *last_frame2 = 0;<br>
> -  const char *prefix = "interception_wrap_";<br>
> +  const char *prefix = "__xsan_";<br>
>   uptr prefix_len = internal_strlen(prefix);<br>
>   const char *path_prefix = flags()->strip_path_prefix;<br>
>   uptr path_prefix_len = internal_strlen(path_prefix);<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
# Meador<br>
</font></span></blockquote></div><br>