[PATCH] A couple minor changes to support sanitizers on FreeBSD 9.2

Viktor Kutuzov vkutuzov at accesssoftek.com
Mon Mar 10 11:18:52 PDT 2014


Hi kcc, samsonov,

http://llvm-reviews.chandlerc.com/D3031

Files:
  lib/asan/asan_linux.cc
  lib/asan/tests/CMakeLists.txt

Index: lib/asan/asan_linux.cc
===================================================================
--- lib/asan/asan_linux.cc
+++ lib/asan/asan_linux.cc
@@ -39,6 +39,17 @@
 #include <sys/ucontext.h>
 #endif
 
+// x64 FreeBSD 9.2 and older define 64-bit register names in both 64-bit
+// and 32-bit modes.
+#if SANITIZER_FREEBSD
+#include <sys/param.h>
+# if __FreeBSD_version <= 902001  // v9.2
+# define mc_eip mc_rip
+# define mc_ebp mc_rbp
+# define mc_esp mc_rsp
+# endif
+#endif
+
 extern "C" void* _DYNAMIC;
 
 namespace __asan {
Index: lib/asan/tests/CMakeLists.txt
===================================================================
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -34,6 +34,13 @@
   -O2)
 append_if(ASAN_UNITTEST_COMMON_CFLAGS COMPILER_RT_HAS_WNO_VARIADIC_MACROS_FLAG -Wno-variadic-macros)
 
+# System headers incorrectly define 'size_t' as 'unsigned long' on
+# x64 FreeBSD 9.2 whereas 'unsigned int' is expected.
+if(CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND
+    CMAKE_SIZEOF_VOID_P MATCHES "8")
+  list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -D_SIZE_T_DECLARED)
+endif()
+
 # Use -D instead of definitions to please custom compile command.
 list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
   -DASAN_HAS_BLACKLIST=1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3031.1.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140310/1f1f6974/attachment.bin>


More information about the llvm-commits mailing list