From patchwork Fri Nov 16 14:03:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Howarth X-Patchwork-Id: 199622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 281A42C0082 for ; Sat, 17 Nov 2012 01:03:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353679412; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=zB9Tqj3FFPvssxMYwkjK WFSLr1M=; b=wJ3aYnlXarr7euLi7cC30lJN0d734o1yfsicGGCWMa46iuon+P8z 8BkiR8XSTgghnYw8ASmm21GJW587wSfHotjJPgdphGlI5f/zY0HZg6Dls5XBPe2G kjcA+69mUr8MA3b5F/6SDDniQ5whD+DCVopl+JkPPI10cyZfOLCjyUk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=M+mesUZYDhlwqbmExsZ5dWUyQ5mRiL96dGBZAaoVMKqyRsJflpIx3r55fYdLoW fZYo67n4afO330SE9s42umvfa4VW6kaKknG2GrXzaKniDhXiFpsEL4UExKUncRkS fNipm5vObI/fgyedTY7OVjFm0riKhyc763eaXKU6/3mIQ=; Received: (qmail 27390 invoked by alias); 16 Nov 2012 14:03:27 -0000 Received: (qmail 27381 invoked by uid 22791); 16 Nov 2012 14:03:26 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_LV, TW_SV X-Spam-Check-By: sourceware.org Received: from bromo.med.uc.edu (HELO bromo.med.uc.edu) (129.137.3.146) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Nov 2012 14:03:20 +0000 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id CF0DCB005C; Fri, 16 Nov 2012 09:03:19 -0500 (EST) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id qAGE3JW6023930; Fri, 16 Nov 2012 09:03:19 -0500 Date: Fri, 16 Nov 2012 09:03:19 -0500 From: Jack Howarth To: Dodji Seketeli Cc: Konstantin Serebryany , gcc-patches@gcc.gnu.org, dnovillo@google.com, jakub@redhat.com, wmi@google.com, davidxl@google.com, Alexander Potapenko , mikestump@comcast.net Subject: Re: [PATCH 00/13] Request to merge Address Sanitizer in Message-ID: <20121116140319.GA23548@bromo.med.uc.edu> References: <1351799566-31447-1-git-send-email-dodji@redhat.com> <20121115194154.GA16078@bromo.med.uc.edu> <87wqxmuf4h.fsf@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87wqxmuf4h.fsf@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Fri, Nov 16, 2012 at 09:27:26AM +0100, Dodji Seketeli wrote: > Jack Howarth writes: > > > The Google branch is missing the required > > interception/mach_override/mach_override.h and > > interception/mach_override/mach_override.c files from compiler-rt svn > > for darwin. I have posted what I believe to be the final patch which > > eanbles libsanitizer on darwin... > > > > http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01285.html > > I see in that thread that Mike Stump has approves the patch if no > asan{-darwin} people disagrees. I'll abide by principle, FWIW. :-) > > > which has been tested with the existing asan testsuite, the > > use-after-free.c testcase as well as the Polyhedron 2005 benchmarks > > for -O1 -g -fno-omit-frame-pointer -faddress-sanitizer and -O3 > > -funroll-loops -ffast-math -g -fno-omit-frame-pointer > > -faddress-sanitizer to prove that the current mach_override from > > upstream is sufficient for darwin to use. > > I see. Thanks. > > > Due to the large number of maintainers for libsanitizer, it is unclear > > who is the person responsible for upstream merges to lobby for these > > files to be ported into gcc trunk. With Alexander Potapenko's commit > > of the bug fix to mach_override/mach_override.c required for FSF > > gcc... > > > > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121112/155989.html > > > > ...there really is no reason to continue to delay (as the interpose code simply won't > > be completed in time for gcc 4.8.0). > > It makes sense to me. > > > Can we please get some movement on importing these missing files from > > upstream? > > Well, given that .... > > Konstantin Serebryany writes: > > > I see no problems with committing mach_override to gcc. > > The code should be verbatim copy from > > llvm/projects/compiler-rt/lib/interception/mach_override > > Note that this code comes with an MIT license and was not developed by > > Google (we did add quite a few patches). > > ... Konstantin who is one of the libsanitizer maintainers agrees, I see > no reason to delay this either. > > So, Jack, as you are on top of this topic and has the platform to test > at hand, I guess you could just import the missing files from the llvm > repository and commit them to GCC, unless a GCC maintainers disagrees, > of course. Can one of the libsanitizer maintainers handle the importation? The only requirements are that they use a mach_override/mach_override.c and mach_override/mach_override.h from on or after llvm r168032... Author: glider Date: Thu Nov 15 02:32:16 2012 New Revision: 168032 URL: http://llvm.org/viewvc/llvm-project?rev=168032&view=rev Log: [ASan] Add the "lea $imm(%rip),%rax" instruction to mach_override.c The need for this has been reported by Jack Howarth (howarth at bromo.med.uc.edu) who's porting ASan-Darwin to GCC Modified: compiler-rt/trunk/lib/interception/mach_override/mach_override.c Modified: compiler-rt/trunk/lib/interception/mach_override/mach_override.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/mach_override/mach_override.c?rev=168032&r1=168031&r2=168032&view=diff and place these two files in libsanitizer/interception/mach_override. I am unclear on what adjustments you are doing to the licensing comments in these files. The imported files could just be tacked onto my posted patch (reattached to this message) and done as a single commit. Thanks in advance. Jack ps I assume that these changes should also be committed to the gcc asan branch as well. > > Thus, you could maybe just send the patch of the file you are about to > commit as a reply to this thread, so that Konstantin and Alexander can > officially ACK it? I am mentioning Alexander because of what Konstantin > is saying ... > > > Also, Alexander Potapenko is the best person to ask about asan-darwin. > > .... here. > > > Maybe we can add him to the list of sanitizer maintainers? > > Seconded. At least for libsanitier/Darwin. > > Cheers. > > -- > Dodji The attached patch assumes that the current mach_override/mach_override.h and mach_override/mach_override.c files have been imported by the libsanitizer maintainers from llvm compiler-rt svn 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. 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. The static linkage of libasan.a in LINK_COMMAND_SPEC_A is handle separately for -static-libstdc++ (which requires libstdc++.a) and the -static, -static-gcc and -static-gfortran cases. 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 the both use-after-free.c testcase and... make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32,-m64}'" without regressions. 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. gcc/ 2012-11-15 Jack Howarth * config/darwin.h (LINK_COMMAND_SPEC_A): Deal with -faddress-sanitizer. libsanitizer/ 2012-11-15 Jack Howarth * 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 193537) +++ libsanitizer/interception/Makefile.am (working copy) @@ -14,7 +14,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 193537) +++ libsanitizer/configure.ac (working copy) @@ -22,6 +22,12 @@ AC_CANONICAL_SYSTEM target_alias=${target_alias-$host_alias} AC_SUBST(target_alias) +case "$host" in + *-*-darwin*) MACH_OVERRIDE=true ;; + *) MACH_OVERRIDE=false ;; +esac +AM_CONDITIONAL(USING_MACH_OVERRIDE, $MACH_OVERRIDE) + AM_INIT_AUTOMAKE(foreign) AM_ENABLE_MULTILIB(, ..) Index: libsanitizer/configure.tgt =================================================================== --- libsanitizer/configure.tgt (revision 193537) +++ 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 ;; Index: gcc/config/darwin.h =================================================================== --- gcc/config/darwin.h (revision 193537) +++ gcc/config/darwin.h (working copy) @@ -180,6 +180,9 @@ 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-libgfortran: -framework CoreFoundation -lstdc++ libasan.a%s; \ + static-libstdc++: -framework CoreFoundation libstdc++.a%s libasan.a%s; : -framework CoreFoundation -lasan } } \ %{fgnu-tm: \ %{static|static-libgcc|static-libstdc++|static-libgfortran: libitm.a%s; : -litm } } \ %{!nostdlib:%{!nodefaultlibs:\ ============================================================================== --- compiler-rt/trunk/lib/interception/mach_override/mach_override.c (original) +++ compiler-rt/trunk/lib/interception/mach_override/mach_override.c Thu Nov 15 02:32:16 2012 @@ -725,6 +725,8 @@ { 0x2, {0xFF, 0x00}, {0x89, 0x00} }, // mov r/m32,r32 or r/m16,r16 { 0x3, {0xFF, 0xFF, 0xFF}, {0x49, 0x89, 0xF8} }, // mov %rdi,%r8 { 0x4, {0xFF, 0xFF, 0xFF, 0xFF}, {0x40, 0x0F, 0xBE, 0xCE} }, // movsbl %sil,%ecx + { 0x7, {0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00}, + {0x48, 0x8D, 0x05, 0x00, 0x00, 0x00, 0x00} }, // lea $imm(%rip),%rax { 0x3, {0xFF, 0xFF, 0xFF}, {0x0F, 0xBE, 0xCE} }, // movsbl, %dh, %ecx { 0x3, {0xFF, 0xFF, 0x00}, {0xFF, 0x77, 0x00} }, // pushq $imm(%rdi) { 0x2, {0xFF, 0xFF}, {0xDB, 0xE3} }, // fninit