diff options
| author | Julian Lettner <jlettner@apple.com> | 2019-04-25 17:46:29 +0000 |
|---|---|---|
| committer | Julian Lettner <jlettner@apple.com> | 2019-04-25 17:46:29 +0000 |
| commit | 8b36610bfa506206149815a9e6448528e9f60b51 (patch) | |
| tree | a7490d782fe6878d7f9d34db494afe0232a548f7 /compiler-rt/lib/interception/interception_linux.cc | |
| parent | c19f4f8069722f6804086d4438a0254104242c46 (diff) | |
| download | bcm5719-llvm-8b36610bfa506206149815a9e6448528e9f60b51.tar.gz bcm5719-llvm-8b36610bfa506206149815a9e6448528e9f60b51.zip | |
[NFC][Sanitizer] Extract GetFuncAddr from GetRealFunctionAddress
Summary:
Hopefully, this will enable cleanup/removal of GetRealFunctionAddress in
follow-up commits.
Subscribers: #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61110
llvm-svn: 359213
Diffstat (limited to 'compiler-rt/lib/interception/interception_linux.cc')
| -rw-r--r-- | compiler-rt/lib/interception/interception_linux.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler-rt/lib/interception/interception_linux.cc b/compiler-rt/lib/interception/interception_linux.cc index 9f2caa25ca4..d019d482d6d 100644 --- a/compiler-rt/lib/interception/interception_linux.cc +++ b/compiler-rt/lib/interception/interception_linux.cc @@ -35,27 +35,32 @@ static int StrCmp(const char *s1, const char *s2) { 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 - if (StrCmp(func_name, "sigaction")) - func_name = "__sigaction14"; + if (StrCmp(name, "sigaction")) + name = "__sigaction14"; #endif - *func_addr = (uptr)dlsym(RTLD_NEXT, func_name); - if (!*func_addr) { + void *addr = dlsym(RTLD_NEXT, name); + if (!addr) { // If the lookup using RTLD_NEXT failed, the sanitizer runtime library is // later in the library search order than the DSO that we are trying to // intercept, which means that we cannot intercept this function. We still // want the address of the real definition, though, so look it up using // RTLD_DEFAULT. - *func_addr = (uptr)dlsym(RTLD_DEFAULT, func_name); + addr = dlsym(RTLD_DEFAULT, name); } - return real == wrapper; + return addr; } // Android and Solaris do not have dlvsym #if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD -void *GetFuncAddrVer(const char *func_name, const char *ver) { - return dlvsym(RTLD_NEXT, func_name, ver); +void *GetFuncAddrVer(const char *name, const char *ver) { + return dlvsym(RTLD_NEXT, name, ver); } #endif // !SANITIZER_ANDROID |

