From patchwork Thu Nov 30 16:40:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 843091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-468244-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kaExhpG0"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ynjnY1xWNz9t7p for ; Fri, 1 Dec 2017 03:40:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=xJl+6nY6Tt9Y+Gnk60GGnnASaB7kejnoA44pHMKtA/MUbDFPS2pp8 AfiOyV4Noo8iHmqyUaB/M94eqeSYfdXGTTLIQ0MVlipOlqsA5bOgCesbkqGN+rUI iZsLIZ3XKPMzMiKpZndzVCMyP1tLZzjaFOluGfpzFjQO7W2l3ws6Gk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=elKL8FsjsZglLhYA2/QivGQqch8=; b=kaExhpG0e1zOM2ofGrGH AQXy8n8y01DaxDDwUnYuyvYwL+Uzp28GO/1z8Y/FEBSIxKF/1VDYA7h6aBExpAXQ 4oO0mJR6SrAEvlYoojsjK6gvGKD/OC4RPQykw5xonZ5xzb5oTRDQjvdE+sZ0vxTf NrRo5dyTUWP1SDxYhCs0u5E= Received: (qmail 105157 invoked by alias); 30 Nov 2017 16:40:23 -0000 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 Received: (qmail 105141 invoked by uid 89); 30 Nov 2017 16:40:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=sk:fstack_ X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Nov 2017 16:40:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 161671596; Thu, 30 Nov 2017 08:40:20 -0800 (PST) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9315C3F318; Thu, 30 Nov 2017 08:40:19 -0800 (PST) From: Thomas Preudhomme Subject: [PATCH, GCC/testsuite] Improve fstack_protector effective target To: Jeff Law , "gcc-patches@gcc.gnu.org" Message-ID: Date: Thu, 30 Nov 2017 16:40:18 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, Effective target fstack_protector fails to return an error for newlib-based target (such as arm-none-eabi targets) which does not support stack protector. This is due to the test being too simplist for stack protection code to be generated by GCC: it does not contain a local buffer and does not read unknown input. This commit adds a small local buffer with a copy of the filename to trigger stack protector code to be generated. The filename is used instead of the full path so as to ensure the size will fit in the local buffer. ChangeLog entry is as follows: *** gcc/testsuite/ChangeLog *** 2017-11-28 Thomas Preud'homme * lib/target-supports.exp (check_effective_target_fstack_protector): Copy filename in local buffer to trigger stack protection. Testing: Ran gcc.dg/pr38616 on arm-none-eabi and arm-linux-gnueabihf, the former is now UNSUPPORTED while the latter continues to PASS. Is this ok for stage3? Best regards, Thomas diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index d30fd368922713d3695f22710197ce7094c977cd..8aff16a25823ec48e76ad6ad8fdc8db998a45877 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1064,7 +1064,11 @@ proc check_effective_target_static {} { # Return 1 if the target supports -fstack-protector proc check_effective_target_fstack_protector {} { return [check_runtime fstack_protector { - int main (void) { return 0; } + #include + int main (int argc, char *argv[]) { + char buf[64]; + return !strcpy (buf, strrchr (argv[0], '/')); + } } "-fstack-protector"] }