[compiler-rt] r359362 - [NFC][Sanitizer] Remove GetRealFunctionAddress and replace usages
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 17:49:14 PDT 2019
Author: yln
Date: Fri Apr 26 17:49:14 2019
New Revision: 359362
URL: http://llvm.org/viewvc/llvm-project?rev=359362&view=rev
Log:
[NFC][Sanitizer] Remove GetRealFunctionAddress and replace usages
Reviewers: vitalybuka
Differential Revision: https://reviews.llvm.org/D61205
Modified:
compiler-rt/trunk/lib/interception/interception_linux.cc
compiler-rt/trunk/lib/interception/interception_linux.h
compiler-rt/trunk/lib/interception/tests/interception_linux_test.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
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=359362&r1=359361&r2=359362&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_linux.cc (original)
+++ compiler-rt/trunk/lib/interception/interception_linux.cc Fri Apr 26 17:49:14 2019
@@ -33,12 +33,6 @@ static int StrCmp(const char *s1, const
}
#endif
-bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
- uptr real, uptr wrapper) {
- *func_addr = (uptr)GetFuncAddr(func_name);
- return real == wrapper;
-}
-
void *GetFuncAddr(const char *name) {
#if SANITIZER_NETBSD
// FIXME: Find a better way to handle renames
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=359362&r1=359361&r2=359362&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_linux.h (original)
+++ compiler-rt/trunk/lib/interception/interception_linux.h Fri Apr 26 17:49:14 2019
@@ -22,26 +22,18 @@
#define INTERCEPTION_LINUX_H
namespace __interception {
-// returns true if a function with the given name was found.
-bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
- uptr real, uptr wrapper);
void *GetFuncAddr(const char *name);
void *GetFuncAddrVer(const char *name, const char *ver);
} // namespace __interception
#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
- do { ::__interception::GetRealFunctionAddress( \
- #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
- (::__interception::uptr) & (func), \
- (::__interception::uptr) & WRAP(func)); \
- } while (0) // TODO(yln): temporarily make macro void.
+ (REAL(func) = (FUNC_TYPE(func)) ::__interception::GetFuncAddr(#func))
// Android, Solaris and OpenBSD do not have dlvsym
#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
-#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
- do { (::__interception::real_##func = (func##_type)( \
- unsigned long)::__interception::GetFuncAddrVer(#func, symver)); \
- } while (0)
+#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
+ (REAL(func) = \
+ (FUNC_TYPE(func)) ::__interception::GetFuncAddrVer(#func, symver))
#else
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
Modified: compiler-rt/trunk/lib/interception/tests/interception_linux_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/tests/interception_linux_test.cc?rev=359362&r1=359361&r2=359362&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/tests/interception_linux_test.cc (original)
+++ compiler-rt/trunk/lib/interception/tests/interception_linux_test.cc Fri Apr 26 17:49:14 2019
@@ -33,17 +33,6 @@ INTERCEPTOR(int, isdigit, int d) {
namespace __interception {
-TEST(Interception, GetRealFunctionAddress) {
- uptr malloc_address = 0;
- EXPECT_TRUE(GetRealFunctionAddress("malloc", &malloc_address, 0, 0));
- EXPECT_NE(0U, malloc_address);
-
- uptr dummy_address = 0;
- EXPECT_TRUE(
- GetRealFunctionAddress("dummy_doesnt_exist__", &dummy_address, 0, 0));
- EXPECT_EQ(0U, dummy_address);
-}
-
TEST(Interception, GetFuncAddr) {
EXPECT_NE(GetFuncAddr("malloc"), nullptr);
EXPECT_EQ(GetFuncAddr("does_not_exist"), nullptr);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=359362&r1=359361&r2=359362&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Fri Apr 26 17:49:14 2019
@@ -573,12 +573,8 @@ TSAN_INTERCEPTOR(int, sigsetjmp, void *e
#endif
#define TSAN_INTERCEPTOR_SETJMP_(x) __interceptor_ ## x
-#define TSAN_INTERCEPTOR_SETJMP__(x) TSAN_INTERCEPTOR_SETJMP_(x)
-#define TSAN_INTERCEPTOR_SETJMP TSAN_INTERCEPTOR_SETJMP__(setjmp_symname)
-#define TSAN_INTERCEPTOR_SIGSETJMP TSAN_INTERCEPTOR_SETJMP__(sigsetjmp_symname)
-
-#define TSAN_STRING_SETJMP SANITIZER_STRINGIFY(setjmp_symname)
-#define TSAN_STRING_SIGSETJMP SANITIZER_STRINGIFY(sigsetjmp_symname)
+#define TSAN_INTERCEPTOR_SETJMP TSAN_INTERCEPTOR_SETJMP_(setjmp_symname)
+#define TSAN_INTERCEPTOR_SIGSETJMP TSAN_INTERCEPTOR_SETJMP_(sigsetjmp_symname)
// Not called. Merely to satisfy TSAN_INTERCEPT().
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
@@ -2643,18 +2639,12 @@ void InitializeInterceptors() {
InitializeSignalInterceptors();
InitializeLibdispatchInterceptors();
-#if !SANITIZER_MAC
- // We can not use TSAN_INTERCEPT to get setjmp addr,
- // because it does &setjmp and setjmp is not present in some versions of libc.
- using __interception::GetRealFunctionAddress;
- GetRealFunctionAddress(TSAN_STRING_SETJMP,
- (uptr*)&REAL(setjmp_symname), 0, 0);
- GetRealFunctionAddress("_setjmp", (uptr*)&REAL(_setjmp), 0, 0);
- GetRealFunctionAddress(TSAN_STRING_SIGSETJMP,
- (uptr*)&REAL(sigsetjmp_symname), 0, 0);
+ TSAN_INTERCEPT(setjmp_symname);
+ TSAN_INTERCEPT(_setjmp);
+ TSAN_INTERCEPT(sigsetjmp_symname);
+
#if !SANITIZER_NETBSD
- GetRealFunctionAddress("__sigsetjmp", (uptr*)&REAL(__sigsetjmp), 0, 0);
-#endif
+ TSAN_INTERCEPT(__sigsetjmp);
#endif
TSAN_INTERCEPT(longjmp_symname);
More information about the llvm-commits
mailing list