summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-04-27 21:20:46 +0000
committerDerek Bruening <bruening@google.com>2016-04-27 21:20:46 +0000
commit41939466d1a5677412891f8d3370c2689e7f759d (patch)
tree45544e38b09082ad36f9d6e6481c1b8b6b68463e
parentaf5aebaa3246a404644a66d4b8e5844ead30aef8 (diff)
downloadbcm5719-llvm-41939466d1a5677412891f8d3370c2689e7f759d.tar.gz
bcm5719-llvm-41939466d1a5677412891f8d3370c2689e7f759d.zip
[sanitizer] Add early call handling to strchr + strrchr interceptors
Summary: The strchr and strrchr interceptors are sometimes invoked too early for their REAL() counterparts to be initialized. We have seen this in hooks invoked from tcmalloc on the dlsym() used in initializing interceptors. A special check is added to use internal_ routines for this situation. Reviewers: vitalybuka, aizatsky, filcab Subscribers: filcab, llvm-commits, eugenis, kcc, zhaoqin, aizatsky, kubabrecka Differential Revision: http://reviews.llvm.org/D19607 llvm-svn: 267793
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 2e0c48e8ed5..85e60caa237 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -401,6 +401,8 @@ INTERCEPTOR(char*, strcasestr, const char *s1, const char *s2) {
#if SANITIZER_INTERCEPT_STRCHR
INTERCEPTOR(char*, strchr, const char *s, int c) {
void *ctx;
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strchr(s, c);
COMMON_INTERCEPTOR_ENTER(ctx, strchr, s, c);
char *result = REAL(strchr)(s, c);
uptr len = internal_strlen(s);
@@ -432,6 +434,8 @@ INTERCEPTOR(char*, strchrnul, const char *s, int c) {
#if SANITIZER_INTERCEPT_STRRCHR
INTERCEPTOR(char*, strrchr, const char *s, int c) {
void *ctx;
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strrchr(s, c);
COMMON_INTERCEPTOR_ENTER(ctx, strrchr, s, c);
uptr len = internal_strlen(s);
if (common_flags()->intercept_strchr)
OpenPOWER on IntegriCloud