From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45286 invoked by alias); 9 Aug 2017 21:16:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 44171 invoked by uid 89); 9 Aug 2017 21:16:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-14.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Attached X-HELO: mail-ua0-f181.google.com Received: from mail-ua0-f181.google.com (HELO mail-ua0-f181.google.com) (209.85.217.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 21:16:11 +0000 Received: by mail-ua0-f181.google.com with SMTP id k43so33688170uaf.3 for ; Wed, 09 Aug 2017 14:16:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=I831/UXMmgYV6vweyJOLj45CebSdQ3D294EwgxW78vU=; b=LygO2Rb4qO2Lrs4STM330SAJS8MZCh75evqwHGVpSiJDjKkRG7uMAmz053GjpBoW/5 00aJRsPi/0hJFTFaZSElAOxC0OqqBrnkPYXqhKu9erdEJobe9Lim7En/Z7qZTgOF5Xek VcKIrxDOgxQ76D2jC88cbSuPl/Ue/yJncyskNCjDi9AK68MDLs0Oj6607DWphHyfF34v VuHt+oAGW4C5KeVPIrHs3cFJHxLaCHIU6Yv+FTQMeuEy9O942dNxygcmC27eTpvC6rol M9PtaGv1nG1xVaBo2vT07UW4QYRgZ13kzapaumvLC/5FxNU8pYL7VRh0gJOqOR/QyZHw XKtw== X-Gm-Message-State: AHYfb5iEb7BdxbML2SaAamWsc+9PZTgxsFdf35PhN0MZ19oL/g7ciKTC wKcPfJSXuTRgDDuW45l7K8SN22SnlKky X-Received: by 10.176.4.111 with SMTP id 102mr7164449uav.146.1502313369915; Wed, 09 Aug 2017 14:16:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.218 with HTTP; Wed, 9 Aug 2017 14:16:09 -0700 (PDT) In-Reply-To: References: From: Uros Bizjak Date: Wed, 09 Aug 2017 21:24:00 -0000 Message-ID: Subject: Re: [PATCH, i386]: Make stack canary location customizable (PR target/81708) To: "gcc-patches@gcc.gnu.org" Cc: Andrew Lutomirski Content-Type: multipart/mixed; boundary="94eb2c056834c1814c0556589681" X-SW-Source: 2017-08/txt/msg00704.txt.bz2 --94eb2c056834c1814c0556589681 Content-Type: text/plain; charset="UTF-8" Content-length: 1458 On Tue, Aug 8, 2017 at 6:54 PM, Uros Bizjak wrote: > Hello! > > Attached patch introduces -mstack-protector-guard-reg= and > -mstack-protector-guard-offset= options to make stack canary location > customizable. These are the same options powerpc has. Attached addition adds -mstack-protector-guard-symbol= option that overrides the offset to TLS stack protector canary with a symbol name. Using this option, stack protector canary can be loaded from specified symbol, relative to guard reg: gcc -O2 -fstack-protector-all -mstack-protector-guard=tls -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=my_guard movq %gs:my_guard(%rip), %rax movq %rax, 8(%rsp) xorl %eax, %eax movq 8(%rsp), %rax xorq %gs:my_guard(%rip), %rax 2017-08-09 Uros Bizjak PR target/81708 * config/i386/i386.opt (mstack-protector-guard-symbol=): New option * config/i386/i386.c (ix86_stack_protect_guard): Use ix86_stack_protect_guard_symbol_str to generate varible declaration. * doc/invoke.texi (x86 Options): Document -mstack-protector-guard-symbol= option. testsuite/ChangeLog: 2017-08-09 Uros Bizjak PR target/81708 * gcc.target/i386/stack-prot-sym.c: New test. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. I plan to commit the patch to mainline SVN in a couple of days. Uros. --94eb2c056834c1814c0556589681 Content-Type: text/plain; charset="US-ASCII"; name="p.diff.txt" Content-Disposition: attachment; filename="p.diff.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j65il2uo1 Content-length: 6552 SW5kZXg6IGNvbmZpZy9pMzg2L2kzODYuYwo9PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09Ci0tLSBjb25maWcvaTM4Ni9pMzg2LmMJKHJldmlzaW9uIDI1MDk5OSkK KysrIGNvbmZpZy9pMzg2L2kzODYuYwkod29ya2luZyBjb3B5KQpAQCAtNDU4 NTgsNiArNDU4NTgsOCBAQCBpeDg2X21hbmdsZV90eXBlIChjb25zdF90cmVl IHR5cGUpCiAgICAgfQogfQogCitzdGF0aWMgR1RZKCgpKSB0cmVlIGl4ODZf dGxzX3N0YWNrX2Noa19ndWFyZF9kZWNsOworCiBzdGF0aWMgdHJlZQogaXg4 Nl9zdGFja19wcm90ZWN0X2d1YXJkICh2b2lkKQogewpAQCAtNDU4NjQsMTUg KzQ1ODY2LDQ3IEBAIGl4ODZfc3RhY2tfcHJvdGVjdF9ndWFyZCAodm9pZCkK ICAgaWYgKFRBUkdFVF9TU1BfVExTX0dVQVJEKQogICAgIHsKICAgICAgIHRy ZWUgdHlwZV9ub2RlID0gbGFuZ19ob29rcy50eXBlcy50eXBlX2Zvcl9tb2Rl IChwdHJfbW9kZSwgMSk7Ci0KICAgICAgIGludCBxdWFsID0gRU5DT0RFX1FV QUxfQUREUl9TUEFDRSAoaXg4Nl9zdGFja19wcm90ZWN0b3JfZ3VhcmRfcmVn KTsKKyAgICAgIHRyZWUgdHlwZSA9IGJ1aWxkX3F1YWxpZmllZF90eXBlICh0 eXBlX25vZGUsIHF1YWwpOworICAgICAgdHJlZSB0OwogCi0gICAgICB0cmVl IHR5cGUgPSBidWlsZF9xdWFsaWZpZWRfdHlwZ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