On Wed, Nov 14, 2012 at 07:00:14PM +0400, Alexander Potapenko wrote: > Hi Jack, > > most certainly the functionality of asan is not intact. > The error messages denote that mach_override couldn't parse some of > the function prologues, which means some of ASan interceptors just > won't work. > In order to fix this you need to change the DEBUG definition in > mach_override.c, look at the bytes being parsed and fix the > instruction table in mach_override.c > Please also send a patch to LLVM containing the fix (sending the patch > to the original mach_override repo makes little sense, because we've > forked it long time ago). > > HTH, > Alex
Alex, I have alway done some of this... http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55289#c11 It seems to be related to the comments found in mach_override.c... #elif defined(__x86_64__) // TODO(glider): disassembling the "0x48, 0x89" sequences is trickier than it's done below. // If it stops working, refer to http://ref.x86asm.net/geek.html#modrm_byte_32_64 to do it // more accurately. // Note: 0x48 is in fact the REX.W prefix, but it might be wrong to treat it as a separate // instruction. It is interesting the the same code for mach_override.h/mach_override.c from llvm-3.2 used under clang 3.2 doesn't trigger this issue. Jack > > On Wed, Nov 14, 2012 at 6:43 PM, Jack Howarth <howa...@bromo.med.uc.edu> > wrote: > > The attached patch assumes that 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 configure.ac. The definition of USING_MACH_OVERRIDE is used in > > Makefile.am as the test for appending mach_override/mach_override.c > > to libinterception_la_SOURCES. Tested on x86_64-apple-darwin12 against > > the mach_override/mach_override.h and mach_override/mach_override.c > > from llvm compiler-rt 3.2 branch. While there is some noise on the > > output of asan... > > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55289#c14 > > > > the functionality of asan appears to be intact. Okay for gcc trunk > > after the libsanitizer maintainers import the missing > > mach_override/mach_override.h > > and mach_override/mach_override.c files? > > Jack > > 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 Patch to configure.tgt revised to use a distinct instance for darwin in > > the case statement and to limit libsanitizer to i?86 and x86_64 on darwin. > > > > libsanitizer/ > > > > 2012-11-14 Jack Howarth <howa...@bromo.med.uc.edu> > > > > * configure.tgt: Add darwin to supported targets. > > * configure.ac: Define USING_MACH_OVERRIDE when on darwin. > > * interception/Makefile.am: Compile mach_override.c when > > USING_MACH_OVERRIDE defined. > > * configure: Regenerated. > > * interception/Makefile.in: Likewise. > > > > Index: libsanitizer/interception/Makefile.am > > =================================================================== > > --- libsanitizer/interception/Makefile.am (revision 193500) > > +++ libsanitizer/interception/Makefile.am (working copy) > > @@ -11,7 +11,11 @@ interception_files = \ > > interception_mac.cc \ > > interception_win.cc > > > > -libinterception_la_SOURCES = $(interception_files) > > +if USING_MACH_OVERRIDE > > +libinterception_la_SOURCES = $(interception_files) > > mach_override/mach_override.c > > +else > > +libinterception_la_SOURCES = $(interception_files) > > +endif > > > > # 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.ac > > =================================================================== > > --- libsanitizer/configure.ac (revision 193500) > > +++ libsanitizer/configure.ac (working copy) > > @@ -17,6 +17,12 @@ AM_PROG_LIBTOOL > > AC_SUBST(enable_shared) > > AC_SUBST(enable_static) > > > > +case "$host" in > > + *-*-darwin*) MACH_OVERRIDE=true ;; > > + *) MACH_OVERRIDE=false ;; > > +esac > > +AM_CONDITIONAL(USING_MACH_OVERRIDE, $MACH_OVERRIDE) > > + > > #AM_ENABLE_MULTILIB(, ..) > > target_alias=${target_alias-$host_alias} > > AC_SUBST(target_alias) > > Index: libsanitizer/configure.tgt > > =================================================================== > > --- libsanitizer/configure.tgt (revision 193500) > > +++ libsanitizer/configure.tgt (working copy) > > @@ -22,6 +22,8 @@ > > case "${target}" in > > x86_64-*-linux* | i?86-*-linux*) > > ;; > > + x86_64-*-darwin* | i?86-*-darwin*) > > + ;; > > *) > > UNSUPPORTED=1 > > ;; > > > > -- > Alexander Potapenko > Software Engineer > Google Moscow