Skip to content

Commit

Permalink
[NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void
Browse files Browse the repository at this point in the history
This temporary change tells us about all the places where the return
value of the INTERCEPT_FUNCTION macro is actually used. In the next
patch I will cleanup the macro and remove GetRealFuncAddress.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D61145

llvm-svn: 359325
  • Loading branch information
yln committed Apr 26, 2019
1 parent c29db2d commit aebd301
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions compiler-rt/lib/asan/asan_interceptors.h
Expand Up @@ -122,12 +122,16 @@ DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
#if !SANITIZER_MAC
#define ASAN_INTERCEPT_FUNC(name) \
do { \
if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \
INTERCEPT_FUNCTION(name); \
bool same = (& (name) == & WRAP(name)); \
if ((!same || !REAL(name))) \
VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \
} while (0)
#define ASAN_INTERCEPT_FUNC_VER(name, ver) \
do { \
if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \
INTERCEPT_FUNCTION_VER(name, ver); \
name##_type ptr = (::__interception::real_##name); \
if ((!ptr || !REAL(name))) \
VReport( \
1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \
} while (0)
Expand Down
10 changes: 6 additions & 4 deletions compiler-rt/lib/interception/interception_linux.h
Expand Up @@ -30,16 +30,18 @@ void *GetFuncAddrVer(const char *name, const char *ver);
} // namespace __interception

#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
::__interception::GetRealFunctionAddress( \
do { ::__interception::GetRealFunctionAddress( \
#func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
(::__interception::uptr) & (func), \
(::__interception::uptr) & WRAP(func))
(::__interception::uptr) & WRAP(func)); \
} while (0) // TODO(yln): temporarily make macro void.

// Android, Solaris and OpenBSD do not have dlvsym
#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
(::__interception::real_##func = (func##_type)( \
unsigned long)::__interception::GetFuncAddrVer(#func, symver))
do { (::__interception::real_##func = (func##_type)( \
unsigned long)::__interception::GetFuncAddrVer(#func, symver)); \
} while (0)
#else
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
Expand Down
8 changes: 6 additions & 2 deletions compiler-rt/lib/msan/msan_interceptors.cc
Expand Up @@ -1243,13 +1243,17 @@ int OnExit() {

#define MSAN_INTERCEPT_FUNC(name) \
do { \
if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \
INTERCEPT_FUNCTION(name); \
bool same = (& (name) == & WRAP(name)); \
if ((!same || !REAL(name))) \
VReport(1, "MemorySanitizer: failed to intercept '" #name "'\n"); \
} while (0)

#define MSAN_INTERCEPT_FUNC_VER(name, ver) \
do { \
if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \
INTERCEPT_FUNCTION_VER(name, ver); \
name##_type ptr = (::__interception::real_##name); \
if ((!ptr || !REAL(name))) \
VReport( \
1, "MemorySanitizer: failed to intercept '" #name "@@" #ver "'\n"); \
} while (0)
Expand Down

0 comments on commit aebd301

Please sign in to comment.