From patchwork Mon Apr 20 16:24:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 462823 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 647DE1400B7 for ; Tue, 21 Apr 2015 02:24:52 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=AzaUHCmn; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=T4lm28aZJARww/42/7JRQH4B7RVnDnU6lUd0nACychN 3U3ZyzjaNVsX8ffygi9Dx9UiVy2kqOf48q5XvVO0ENmVrPQUsQO+UVawXF7VvwWc RFSpMbaSvj6DkQNZyAFgElPoLzQFqLsl71kaf/pk2Dxw6f8WmRwogR1D6QqH5NEA = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=225E6xOeoOeO9/VpHByaNPvXGUg=; b=AzaUHCmnig/rwcIVu 2GmrVUaN/b+O8Zli6dovf1bgWUtTwQZ7gdxr5WmetgJdT4Vz+i5PtwKqE7ge90ZX mgoMqPhp8tw3zXeK0LZ+2JZUnwSuNWnjj0sdinSWwv2A8ND7lLgR4GQb9/NuCw6D CuJxAOsgJpQ+hT+lZJMWediTL4= Received: (qmail 4786 invoked by alias); 20 Apr 2015 16:24:44 -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 4768 invoked by uid 89); 20 Apr 2015 16:24:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Apr 2015 16:24:42 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-26.uk.mimecast.lan; Mon, 20 Apr 2015 17:24:39 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 20 Apr 2015 17:24:39 +0100 Message-ID: <55352847.8080302@arm.com> Date: Mon, 20 Apr 2015 17:24:39 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: [PATCH][AArch64] Increase static buffer size in aarch64_rewrite_selected_cpu X-MC-Unique: B1gAEWiuTA6CpRmA7ZsgQA-1 X-IsSubscribed: yes Hi all, When trying to compile a testcase with -mcpu=cortex-a57+crypto+nocrc I got the weird assembler error: Assembler messages: Error: missing architectural extension Error: unrecognized option -mcpu=cortex-a57+crypto+no The problem is the aarch64_rewrite_selected_cpu that is used to rewrite -mcpu for big.LITTLE options has a limit of 20 characters in what it handles, which we can exhaust quickly if we specify architectural extensions in a fine-grained manner. This patch increases that character limit to 128 and adds an assert to confirm that no bad things happen. It also fixes another problem: If we pass a big.LITTLE combination with feature modifiers like: -mcpu=cortex-a57.cortex-a53+nosimd the code will truncate everything after '.', thus destroying the extensions that we want to pass. The patch adds code to stitch the extensions back on after the LITTLE cpu is removed. Tested aarch64-none-elf and made sure the given mcpu option works fine with the assembler. Ok for trunk? Thanks, Kyrill 2015-04-20 Kyrylo Tkachov * common/config/aarch64/aarch64-common.c (AARCH64_CPU_NAME_LENGTH): Increase to 128. (aarch64_rewrite_selected_cpu): Do not chop off extensions starting at '.'. Assert that there's enough space for everything. commit 9623c859d5f4d0da1a364184bf0ce0dbbc7907b4 Author: Kyrylo Tkachov Date: Thu Feb 19 17:05:48 2015 +0000 [AArch64] Increase static buffer size in aarch64_rewrite_selected_cpu diff --git a/gcc/common/config/aarch64/aarch64-common.c b/gcc/common/config/aarch64/aarch64-common.c index 308f19c..b3fd9dc 100644 --- a/gcc/common/config/aarch64/aarch64-common.c +++ b/gcc/common/config/aarch64/aarch64-common.c @@ -27,6 +27,7 @@ #include "common/common-target-def.h" #include "opts.h" #include "flags.h" +#include "errors.h" #ifdef TARGET_BIG_ENDIAN_DEFAULT #undef TARGET_DEFAULT_TARGET_FLAGS @@ -89,23 +90,34 @@ aarch64_handle_option (struct gcc_options *opts, struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; -#define AARCH64_CPU_NAME_LENGTH 20 +#define AARCH64_CPU_NAME_LENGTH 128 -/* Truncate NAME at the first '.' character seen, or return - NAME unmodified. */ +/* Truncate NAME at the first '.' character seen up to the first '+' + or return NAME unmodified. */ const char * aarch64_rewrite_selected_cpu (const char *name) { static char output_buf[AARCH64_CPU_NAME_LENGTH + 1] = {0}; - char *arg_pos; + const char *bL_sep; + const char *feats; + size_t pref_size; + size_t feat_size; - strncpy (output_buf, name, AARCH64_CPU_NAME_LENGTH); - arg_pos = strchr (output_buf, '.'); + bL_sep = strchr (name, '.'); + if (!bL_sep) + return name; - /* If we found a '.' truncate the entry at that point. */ - if (arg_pos) - *arg_pos = '\0'; + feats = strchr (name, '+'); + feat_size = feats ? strnlen (feats, AARCH64_CPU_NAME_LENGTH) : 0; + pref_size = bL_sep - name; + + if ((feat_size + pref_size) > AARCH64_CPU_NAME_LENGTH) + internal_error ("-mcpu string too large"); + + strncpy (output_buf, name, pref_size); + if (feats) + strncpy (output_buf + pref_size, feats, feat_size); return output_buf; }