summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2012-03-23 11:33:02 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2012-03-23 11:33:02 +0000
commit72859836ab769ec5cd743daa2f93977ddbc427c6 (patch)
treeafef330ae13f216846a8911356469c617f96e227
parentcbf108eda6346ebff05af892fc5d4d9df2982802 (diff)
downloadbcm5719-llvm-72859836ab769ec5cd743daa2f93977ddbc427c6.tar.gz
bcm5719-llvm-72859836ab769ec5cd743daa2f93977ddbc427c6.zip
[ASan] Add a few more malloc-related interceptors for Windows
llvm-svn: 153327
-rw-r--r--compiler-rt/lib/asan/asan_malloc_win.cc47
1 files changed, 45 insertions, 2 deletions
diff --git a/compiler-rt/lib/asan/asan_malloc_win.cc b/compiler-rt/lib/asan/asan_malloc_win.cc
index 2235616106f..42ba8fe08e4 100644
--- a/compiler-rt/lib/asan/asan_malloc_win.cc
+++ b/compiler-rt/lib/asan/asan_malloc_win.cc
@@ -34,19 +34,34 @@ void free(void *ptr) {
return asan_free(ptr, &stack);
}
+void _free_dbg(void* ptr, int) {
+ free(ptr);
+}
+
+void cfree(void *ptr) {
+ CHECK(!"cfree() should not be used on Windows?");
+}
+
void *malloc(size_t size) {
GET_STACK_TRACE_HERE_FOR_MALLOC;
return asan_malloc(size, &stack);
}
+void* _malloc_dbg(size_t size, int , const char*, int) {
+ return malloc(size);
+}
+
void *calloc(size_t nmemb, size_t size) {
GET_STACK_TRACE_HERE_FOR_MALLOC;
return asan_calloc(nmemb, size, &stack);
}
+void* _calloc_dbg(size_t n, size_t size, int, const char*, int) {
+ return calloc(n, size);
+}
+
void *_calloc_impl(size_t nmemb, size_t size, int *errno_tmp) {
- GET_STACK_TRACE_HERE_FOR_MALLOC;
- return asan_calloc(nmemb, size, &stack);
+ return calloc(nmemb, size);
}
void *realloc(void *ptr, size_t size) {
@@ -54,10 +69,38 @@ void *realloc(void *ptr, size_t size) {
return asan_realloc(ptr, size, &stack);
}
+void *_realloc_dbg(void *ptr, size_t size, int) {
+ CHECK(!"_realloc_dbg should not exist!");
+ return NULL;
+}
+
+void* _recalloc(void* p, size_t n, size_t elem_size) {
+ if (!p)
+ return calloc(n, elem_size);
+ const size_t size = n * elem_size;
+ if (elem_size != 0 && size / elem_size != n)
+ return NULL;
+ return realloc(p, size);
+}
+
size_t _msize(void *ptr) {
GET_STACK_TRACE_HERE_FOR_MALLOC;
return asan_malloc_usable_size(ptr, &stack);
}
+
+int _CrtDbgReport(int, const char*, int,
+ const char*, const char*, ...) {
+ ShowStatsAndAbort();
+}
+
+int _CrtDbgReportW(int reportType, const wchar_t*, int,
+ const wchar_t*, const wchar_t*, ...) {
+ ShowStatsAndAbort();
+}
+
+int _CrtSetReportMode(int, int) {
+ return 0;
+}
} // extern "C"
using __interception::GetRealFunctionAddress;
OpenPOWER on IntegriCloud