From patchwork Mon Jul 9 20:51:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Zamyatin X-Patchwork-Id: 169956 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 6DB252C01FA for ; Tue, 10 Jul 2012 06:51:25 +1000 (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=1342471886; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=4eFQMb+/sbfCT6e8LaCdoNuKQWQ=; b=Pl0kl5NDmQGRrNTu1Wv3yw+IhnsATPin/K7uIIZVLXgo1JUYJfLIhWqvYdNIVg 96cjPamXHLXakh4V+kAdaD6kUDvtk7spLt9fh8XO/YwXLp+NYc5UlseLeDLhAHSX joj3vdVjJTPGK3Fl+78VMWz4h8HxWuTy4FlzxM9mw21+I= 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:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=X9XCxLfQtFeUgTirH5PJA7CI8FH9J1BXgZjUrELJULgoG8TW/wP5f8JcZzOVu8 CGBuhG84dmp2AdUogIdtQzGpxe+bFdZOtg/XHTI9CFssbkYmqw01em2PmhxWkXxO nS7zg+sWjog2wfWXQsrfXSOotb056ZxZ7AYSa1zIba/L0=; Received: (qmail 26030 invoked by alias); 9 Jul 2012 20:51:20 -0000 Received: (qmail 26020 invoked by uid 22791); 9 Jul 2012 20:51:19 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Jul 2012 20:51:06 +0000 Received: by pbbrq2 with SMTP id rq2so20029458pbb.20 for ; Mon, 09 Jul 2012 13:51:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.134.201 with SMTP id pm9mr64562912pbb.49.1341867065761; Mon, 09 Jul 2012 13:51:05 -0700 (PDT) Received: by 10.68.65.52 with HTTP; Mon, 9 Jul 2012 13:51:05 -0700 (PDT) In-Reply-To: References: Date: Tue, 10 Jul 2012 00:51:05 +0400 Message-ID: Subject: Re: [PATCH, Android] Runtime stack protector enabling for Android target From: Igor Zamyatin To: gcc-patches@gcc.gnu.org Cc: Maxim Kuvyrkov 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 Let's try with this patch then. Is it ok for trunk after all appropriate testing is done? ChangeLog: 2012-07-09 Sergey Melnikov * config/i386/i386.md (stack_protect_set): Disable the pattern for Android since Android libc (bionic) does not provide random value for stack protection guard at gs:0x14. Guard value will be provided from external symbol (default implementation). (stack_protect_set_): Likewise. (stack_protect_test): Likewise. (stack_protect_test_): Likewise. @@ -17997,7 +17997,7 @@ [(match_operand 0 "memory_operand" "") (match_operand 1 "memory_operand" "") (match_operand 2 "" "")] - "" + "!(flag_android && OPTION_BIONIC)" { rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG); @@ -18027,7 +18027,7 @@ (match_operand:P 2 "memory_operand" "m")] UNSPEC_SP_TEST)) (clobber (match_scratch:P 3 "=&r"))] - "" + "!(flag_android && OPTION_BIONIC)" "mov{}\t{%1, %3|%3, %1}\;xor{}\t{%2, %3|%3, %2}" [(set_attr "type" "multi")]) Thanks, Igor On Fri, Jul 6, 2012 at 4:54 PM, Igor Zamyatin wrote: > Right, flag_android looks better, thanks. > Probably it's even better to check also bionic (OPTION_BIONIC) > > On Fri, Jul 6, 2012 at 12:13 PM, Andrew Pinski wrote: >> On Fri, Jul 6, 2012 at 12:49 AM, Igor Zamyatin wrote: >>> Hi! >>> >>> For runtime stack protector enabling on x86 for Android we have to >>> disable current glibc-based implementation and turn on default one >>> since bionic doesn't use value from gs:0x14. >>> >>> Tested in android environment(x86_64-*-linux-android), also >>> bootstrapped and regtested on x86_64-unknown-linux-gnu and i686-linux. >>> Ok for trunk? >> >> >> >> I think you want flag_android and not ANDROID_DEFAULT since you could >> use -mno-android . >> >> Thanks, >> Andrew >> >> >> >>> >>> Thanks, >>> Igor >>> >>> diff --git a/gcc-4.6/gcc/config/i386/i386.md b/gcc-4.6/gcc/config/i386/i386.md index b1d7e5e..c4dd6e3 100644 --- a/gcc-4.6/gcc/config/i386/i386.md +++ b/gcc-4.6/gcc/config/i386/i386.md @@ -17955,7 +17955,7 @@ (define_expand "stack_protect_set" [(match_operand 0 "memory_operand" "") (match_operand 1 "memory_operand" "")] - "" + "!(flag_android && OPTION_BIONIC)" { rtx (*insn)(rtx, rtx); @@ -17979,7 +17979,7 @@ (unspec:P [(match_operand:P 1 "memory_operand" "m")] UNSPEC_SP_SET)) (set (match_scratch:P 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] - "" + "!(flag_android && OPTION_BIONIC)" "mov{}\t{%1, %2|%2, %1}\;mov{}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" [(set_attr "type" "multi")])