summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-04-07 18:07:09 +0000
committerDerek Bruening <bruening@google.com>2016-04-07 18:07:09 +0000
commita7685389c8ccdf02c48318c3603b41448f628ed7 (patch)
tree618b4cf0a1cbd6e0afa72217d4bf34ce938d904a /compiler-rt/lib/sanitizer_common
parent42795bdc76650a6c27553306db21bd0deb2ac653 (diff)
downloadbcm5719-llvm-a7685389c8ccdf02c48318c3603b41448f628ed7.tar.gz
bcm5719-llvm-a7685389c8ccdf02c48318c3603b41448f628ed7.zip
[sanitizer] Add early call handling to strlen interceptor
Summary: The strlen interceptor is sometimes invoked too early for REAL(strlen) to be initialized. A special check is added to use internal_strlen for this situation. Reviewers: dim Subscribers: llvm-commits, samsonov Differential Revision: http://reviews.llvm.org/D18851 Change-Id: I3acc58f4abbae1904f25324abd84efea67aad0a2 llvm-svn: 265705
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc6
1 files changed, 6 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 e531f047baa..2e0c48e8ed5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -206,6 +206,12 @@ UNUSED static void DeleteInterceptorMetadata(void *addr) {
#if SANITIZER_INTERCEPT_STRLEN
INTERCEPTOR(SIZE_T, strlen, const char *s) {
+ // Sometimes strlen is called prior to InitializeCommonInterceptors,
+ // in which case the REAL(strlen) typically used in
+ // COMMON_INTERCEPTOR_ENTER will fail. We use internal_strlen here
+ // to handle that.
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strlen(s);
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, strlen, s);
SIZE_T result = REAL(strlen)(s);
OpenPOWER on IntegriCloud