From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 16:24:00 -0000 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 Content-Type: multipart/mixed; boundary="------------050203020505020906070203" X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg01046.txt.bz2 This is a multi-part message in MIME format. --------------050203020505020906070203 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1325 Hi all, When trying to compile a testcase with -mcpu=3Dcortex-a57+crypto+nocrc I go= t the weird assembler error: Assembler messages: Error: missing architectural extension Error: unrecognized option -mcpu=3Dcortex-a57+crypto+no The problem is the aarch64_rewrite_selected_cpu that is used to rewrite -mc= pu for big.LITTLE options has a limit of 20 characters in what it handles, which we can exhaust quick= ly if we specify architectural extensions in a fine-grained manner. This patch increases that character limit to 128 and adds an assert to conf= irm that no bad things happen. It also fixes another problem: If we pass a big.LITTLE combination with fea= ture modifiers like: -mcpu=3Dcortex-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 i= s 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. --------------050203020505020906070203 Content-Type: text/x-patch; name=aarch64-cpu-name-length.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="aarch64-cpu-name-length.patch" Content-length: 1956 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" =20 #ifdef TARGET_BIG_ENDIAN_DEFAULT #undef TARGET_DEFAULT_TARGET_FLAGS @@ -89,23 +90,34 @@ aarch64_handle_option (struct gcc_options *opts, =20 struct gcc_targetm_common targetm_common =3D TARGETM_COMMON_INITIALIZER; =20 -#define AARCH64_CPU_NAME_LENGTH 20 +#define AARCH64_CPU_NAME_LENGTH 128 =20 -/* 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. */ =20 const char * aarch64_rewrite_selected_cpu (const char *name) { static char output_buf[AARCH64_CPU_NAME_LENGTH + 1] =3D {0}; - char *arg_pos; + const char *bL_sep; + const char *feats; + size_t pref_size; + size_t feat_size; =20 - strncpy (output_buf, name, AARCH64_CPU_NAME_LENGTH); - arg_pos =3D strchr (output_buf, '.'); + bL_sep =3D strchr (name, '.'); + if (!bL_sep) + return name; =20 - /* If we found a '.' truncate the entry at that point. */ - if (arg_pos) - *arg_pos =3D '\0'; + feats =3D strchr (name, '+'); + feat_size =3D feats ? strnlen (feats, AARCH64_CPU_NAME_LENGTH) : 0; + pref_size =3D 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); =20 return output_buf; } --------------050203020505020906070203--