This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][Revisedx2] Enable libsanitizer on darwin

   The attached patch assumes that the current mach_override/mach_override.h
and mach_override/mach_override.c has been imported by the libsanitizer
maintainers for use by darwin. The patch adds darwin to the supported
target list in configure.tgt and defines USING_MACH_OVERRIDE for darwin
in The definition of USING_MACH_OVERRIDE is used in as the test for appending mach_override/mach_override.c
to libinterception_la_SOURCES. LINK_COMMAND_SPEC_A in gcc/config/darwin.h
is modified to add an entry to handle faddress-sanitizer so that the
required linkages are used for libasan. Tested on x86_64-apple-darwin12 against
the mach_override/mach_override.h and mach_override/mach_override.c
from llvm compiler-rt svn for both -m32 and -m64 with both use-after-free.c
testcase and make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32,-m64}'"
without regressions.
ps Note that this patch assumes that both mach_override.h and mach_override.c
reside in a mach_override subdirectory in interception as is the case in the
llvm's compiler-rt.
pps The libsanitizer/ is readjusted for the bit-rot in the previous
patch due to the checkin of libsanitizer multilib support (which is functional
with this patch).


2012-11-15  Jack Howarth <>

	* config/darwin.h (LINK_COMMAND_SPEC_A): Deal with -faddress-sanitizer.


2012-11-15  Jack Howarth <>

	* configure.tgt: Add darwin to supported targets.
	* Define USING_MACH_OVERRIDE when on darwin.
	* interception/ Compile mach_override.c when
	* configure: Regenerated.
	* interception/ Likewise.

Index: libsanitizer/
--- libsanitizer/	(revision 193532)
+++ libsanitizer/	(working copy)
@@ -22,6 +22,12 @@ AC_CANONICAL_SYSTEM
+case "$host" in
+  *-*-darwin*) MACH_OVERRIDE=true ;;
+  *) MACH_OVERRIDE=false ;;
Index: libsanitizer/interception/
--- libsanitizer/interception/	(revision 193532)
+++ libsanitizer/interception/	(working copy)
@@ -11,7 +11,11 @@ interception_files = \ \
-libinterception_la_SOURCES = $(interception_files) 
+libinterception_la_SOURCES = $(interception_files) mach_override/mach_override.c
+libinterception_la_SOURCES = $(interception_files)
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
Index: libsanitizer/configure.tgt
--- libsanitizer/configure.tgt	(revision 193532)
+++ libsanitizer/configure.tgt	(working copy)
@@ -22,6 +22,8 @@
 case "${target}" in
   x86_64-*-linux* | i?86-*-linux*)
+  x86_64-*-darwin* | i?86-*-darwin*)
+	;;
Index: gcc/config/darwin.h
--- gcc/config/darwin.h	(revision 193532)
+++ gcc/config/darwin.h	(working copy)
@@ -180,6 +180,8 @@ extern GTY(()) int darwin_ms_struct;
     %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
     %{fopenmp|ftree-parallelize-loops=*: \
       %{static|static-libgcc|static-libstdc++|static-libgfortran: libgomp.a%s; : -lgomp } } \
+    %{faddress-sanitizer: \
+      %{static|static-libgcc|static-libstdc++|static-libgfortran: -framework CoreFoundation libasan.a%s; : -framework CoreFoundation -lasan } } \
     %{fgnu-tm: \
       %{static|static-libgcc|static-libstdc++|static-libgfortran: libitm.a%s; : -litm } } \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]