[llvm-commits] [compiler-rt] r148726 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_interceptors.h
Kostya Serebryany
kcc at google.com
Mon Jan 23 13:20:05 PST 2012
Author: kcc
Date: Mon Jan 23 15:20:05 2012
New Revision: 148726
URL: http://llvm.org/viewvc/llvm-project?rev=148726&view=rev
Log:
[asan] use internal_strcmp before asan_init is done. *may* fix asan issue #30
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_interceptors.h
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=148726&r1=148725&r2=148726&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Mon Jan 23 15:20:05 2012
@@ -235,6 +235,18 @@
return dst;
}
+int internal_strcmp(const char *s1, const char *s2) {
+ while (true) {
+ unsigned c1 = *s1;
+ unsigned c2 = *s2;
+ if (c1 != c2) return (c1 < c2) ? -1 : 1;
+ if (c1 == 0) break;
+ s1++;
+ s2++;
+ }
+ return 0;
+}
+
} // namespace __asan
// ---------------------- Wrappers ---------------- {{{1
@@ -490,10 +502,8 @@
extern "C"
int WRAP(strcmp)(const char *s1, const char *s2) {
- // strcmp is called from malloc_default_purgeable_zone()
- // in __asan::ReplaceSystemAlloc() on Mac.
- if (asan_init_is_running) {
- return real_strcmp(s1, s2);
+ if (!asan_inited) {
+ return internal_strcmp(s1, s2);
}
unsigned char c1, c2;
size_t i;
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=148726&r1=148725&r2=148726&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h Mon Jan 23 15:20:05 2012
@@ -70,6 +70,7 @@
int internal_memcmp(const void* s1, const void* s2, size_t n);
char *internal_strstr(const char *haystack, const char *needle);
char *internal_strncat(char *dst, const char *src, size_t n);
+int internal_strcmp(const char *s1, const char *s2);
void InitializeAsanInterceptors();
More information about the llvm-commits
mailing list