From patchwork Wed Jul 31 11:19:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Blinov X-Patchwork-Id: 1139675 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-505903-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EGDmUFk7"; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.b="CXWprpNp"; 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 45z9tP52Twz9s00 for ; Wed, 31 Jul 2019 21:19:23 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=YnczyQzHyifWU3x2 ewnIl+tpWv/9Bk2h7jKzW6S/a9JDLrGzrieA3nYPVYpCdHR9RXaEXwhSNvY1ML4P oncBXcjhr+gRLc0iMiUVWClL5EbVn3ZRqP+vjMO/UCqaCwGkHkZGTqjh7gvdXS/c e52xSchJ116XZr8OoBr4iyOM/GQ= 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 :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=iKVsxT1XP31f+jCDKxlmSb YQMIg=; b=EGDmUFk7Mg5cgd6ZoD9RCeXv7O3UnQO/WftbGAau3y6A1Tcikm2tmW guEA6giDbecIZ0MNid9PL2Q4cToiD2yIM0FAxw1C9trxGDvjADMK0DBdULev+UNZ 9PY3UwbynxiId/ReCiqpcYI70I3jHaAhZNzCo0zXtDGoSSYv7d7bc= Received: (qmail 408 invoked by alias); 31 Jul 2019 11:19:16 -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 396 invoked by uid 89); 31 Jul 2019 11:19:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-wr1-f49.google.com Received: from mail-wr1-f49.google.com (HELO mail-wr1-f49.google.com) (209.85.221.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jul 2019 11:19:14 +0000 Received: by mail-wr1-f49.google.com with SMTP id y4so69251674wrm.2 for ; Wed, 31 Jul 2019 04:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E+0kIYfmp/E1pg/al6VVrC16KNXqb8q8dqhZaV9vuA4=; b=CXWprpNp2HCgZLt3xWJAHPZYRuknzzEi4PDbh9pjTNMvSX/FopgJznEgwI2C9OcM9n L8rYs4u9h+yacjh+GE8F3uDM1NFmg2GhzR94P2jz9u2sDccyOYuLlpbpF3HB+valeuDR SaHFah+WE7RA9hJfRli+uGEIVQ5fDq0QZ6K0+/XwbhV3Eo+VYxNBmdbEGPt6dvvvoeFn rqzolW9RQSCG664yBoxifoG1ois9cxTuLwisNf7gmDHTCy47T7wlVGEqL8t35KciAlEX pIuHkeBAGtmR+lgwJsd+e9Sr+NZUeP31VfwXpEfK6SbPJKJIBDSVB+2nX7H0uP7f2+zN yzuA== Received: from maxim-ThinkPad-T490.lym.embecosm-corp.com (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id r12sm82825263wrt.95.2019.07.31.04.19.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 04:19:10 -0700 (PDT) From: Maxim Blinov To: gcc-patches@gcc.gnu.org Cc: Maxim Blinov Subject: [PATCH] RISC-V: Raise error on unexpected ISA string at end. Date: Wed, 31 Jul 2019 12:19:00 +0100 Message-Id: <20190731111900.13202-1-maxim.blinov@embecosm.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch adds the same check that is present in binutils/bfd/elfxx-riscv.c. Checks that we have reached the end of the string after all the parsing routines have been run. Without this check, GCC silently succeeds on erroneous input, and produces an assembly with a truncated arch attribute. tested with RUNTESTFLAGS="riscv.exp" Thanks, Maxim gcc/ChangeLog: 2019-07-31 Maxim Blinov * common/config/riscv/riscv-common.c: Check -march string ends with null. gcc/testsuite/ChangeLog: 2019-07-31 Maxim Blinov * gcc.target/riscv/attribute-10.c: New test. --- gcc/common/config/riscv/riscv-common.c | 7 +++++++ gcc/testsuite/gcc.target/riscv/attribute-10.c | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/attribute-10.c diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c index eeb75717db0..64a309241da 100644 --- a/gcc/common/config/riscv/riscv-common.c +++ b/gcc/common/config/riscv/riscv-common.c @@ -513,6 +513,13 @@ riscv_subset_list::parse (const char *arch, location_t loc) if (p == NULL) goto fail; + if (*p != '\0') + { + error_at (loc, "-march=%s: unexpected ISA string at end: %<%s%>", + arch, p); + goto fail; + } + return subset_list; fail: diff --git a/gcc/testsuite/gcc.target/riscv/attribute-10.c b/gcc/testsuite/gcc.target/riscv/attribute-10.c new file mode 100644 index 00000000000..dd817879a67 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/attribute-10.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32im_s_sx_unexpectedstring -mabi=ilp32" } */ +int foo() +{ +} +/* { dg-error "unexpected ISA string at end:" "" { target { "riscv*-*-*" } } 0 } */