[PATCH] Fix for size_t in Asan's new and delete operators on x64 FreeBSD in 32-bit mode
Viktor Kutuzov
vkutuzov at accesssoftek.com
Fri Feb 21 08:58:24 PST 2014
Rewritten with an anonymous namespace.
Nice idea. Thanks!
Hi kcc, samsonov,
http://llvm-reviews.chandlerc.com/D2856
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2856?vs=7279&id=7285#toc
Files:
lib/asan/asan_new_delete.cc
Index: lib/asan/asan_new_delete.cc
===================================================================
--- lib/asan/asan_new_delete.cc
+++ lib/asan/asan_new_delete.cc
@@ -49,15 +49,25 @@
// To make sure that C++ allocation/deallocation operators are overridden on
// OS X we need to intercept them using their mangled names.
#if !SANITIZER_MAC
+namespace {
+// System headers define 'size_t' incorrectly on x64 FreeBSD when
+// compiled in 32-bit mode.
+#if SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 32
+typedef unsigned xsize_t;
+#else
+typedef size_t xsize_t;
+#endif
+} // namespace
+
INTERCEPTOR_ATTRIBUTE
-void *operator new(size_t size) { OPERATOR_NEW_BODY(FROM_NEW); }
+void *operator new(xsize_t size) { OPERATOR_NEW_BODY(FROM_NEW); }
INTERCEPTOR_ATTRIBUTE
-void *operator new[](size_t size) { OPERATOR_NEW_BODY(FROM_NEW_BR); }
+void *operator new[](xsize_t size) { OPERATOR_NEW_BODY(FROM_NEW_BR); }
INTERCEPTOR_ATTRIBUTE
-void *operator new(size_t size, std::nothrow_t const&)
+void *operator new(xsize_t size, std::nothrow_t const&)
{ OPERATOR_NEW_BODY(FROM_NEW); }
INTERCEPTOR_ATTRIBUTE
-void *operator new[](size_t size, std::nothrow_t const&)
+void *operator new[](xsize_t size, std::nothrow_t const&)
{ OPERATOR_NEW_BODY(FROM_NEW_BR); }
#else // SANITIZER_MAC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2856.2.patch
Type: text/x-patch
Size: 1289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140221/789316a6/attachment.bin>
More information about the llvm-commits
mailing list