[PATCH] D69051: Handle libhwasan system allocator fallback during thread initialisation
Matthew Malcomson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 10:14:20 PDT 2019
mmalcomson updated this revision to Diff 225457.
mmalcomson added a comment.
Remove some superfluous semicolons that were causing warnings.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69051/new/
https://reviews.llvm.org/D69051
Files:
compiler-rt/lib/hwasan/hwasan_allocator.cpp
compiler-rt/lib/hwasan/hwasan_allocator.h
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
Index: compiler-rt/lib/hwasan/hwasan_interceptors.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -359,6 +359,8 @@
#endif // __aarch64__
INTERCEPT_FUNCTION(realloc);
INTERCEPT_FUNCTION(free);
+ INTERCEPT_FUNCTION(malloc);
+ INTERCEPT_FUNCTION(calloc);
#endif
inited = 1;
Index: compiler-rt/lib/hwasan/hwasan_allocator.h
===================================================================
--- compiler-rt/lib/hwasan/hwasan_allocator.h
+++ compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -29,6 +29,8 @@
#if HWASAN_WITH_INTERCEPTORS
DECLARE_REAL(void *, realloc, void *ptr, uptr size)
DECLARE_REAL(void, free, void *ptr)
+DECLARE_REAL(void *, malloc, SIZE_T size)
+DECLARE_REAL(void *, calloc, SIZE_T nmemb, SIZE_T size)
#endif
namespace __hwasan {
Index: compiler-rt/lib/hwasan/hwasan_allocator.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ compiler-rt/lib/hwasan/hwasan_allocator.cpp
@@ -25,6 +25,8 @@
#if HWASAN_WITH_INTERCEPTORS
DEFINE_REAL(void *, realloc, void *ptr, uptr size)
DEFINE_REAL(void, free, void *ptr)
+DEFINE_REAL(void *, malloc, SIZE_T size)
+DEFINE_REAL(void *, calloc, SIZE_T nmemb, SIZE_T size)
#endif
namespace __hwasan {
@@ -120,6 +122,13 @@
Thread *t = GetCurrentThread();
void *allocated;
if (t) {
+#if HWASAN_WITH_INTERCEPTORS
+ if (t->TaggingIsDisabled() && !flags()->disable_allocator_tagging)
+ if (zeroise)
+ return REAL(calloc)(1, orig_size);
+ else
+ return REAL(malloc)(orig_size);
+#endif
allocated = allocator.Allocate(t->allocator_cache(), size, alignment);
} else {
SpinMutexLock l(&fallback_mutex);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69051.225457.patch
Type: text/x-patch
Size: 1811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191017/dca2d578/attachment.bin>
More information about the llvm-commits
mailing list