From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61108 invoked by alias); 7 Sep 2015 14:46:35 -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 61097 invoked by uid 89); 7 Sep 2015 14:46:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f181.google.com Received: from mail-wi0-f181.google.com (HELO mail-wi0-f181.google.com) (209.85.212.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 07 Sep 2015 14:46:33 +0000 Received: by wiclk2 with SMTP id lk2so86560120wic.1 for ; Mon, 07 Sep 2015 07:46:30 -0700 (PDT) X-Received: by 10.180.108.175 with SMTP id hl15mr35302629wib.1.1441637190774; Mon, 07 Sep 2015 07:46:30 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.55.41]) by smtp.gmail.com with ESMTPSA id ej5sm20465494wjd.22.2015.09.07.07.46.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 07:46:30 -0700 (PDT) Date: Mon, 07 Sep 2015 14:48:00 -0000 From: Ilya Verbin To: Jakub Jelinek Cc: "Hahnfeld, Jonas" , "gcc-patches@gcc.gnu.org" , Kirill Yukhin , Mike Stump Subject: Re: Fix intelmic-mkoffload.c if the temp path contains a '-' Message-ID: <20150907144612.GA5256@msticlxl57.ims.intel.com> References: <20150901115012.GQ1847@tucnak.redhat.com> <4481C24E-AB27-4E2B-AEE6-2E813C0925DB@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00444.txt.bz2 On Sat, Sep 05, 2015 at 00:45:36 +0300, Ilya Verbin wrote: > 2015-09-04 22:27 GMT+03:00 Mike Stump : > > On Sep 4, 2015, at 4:10 AM, Hahnfeld, Jonas wrote: > >>>>> * intelmic-mkoffload.c (prepare_target_image): Fix if the temp path > >>>>> contains a '-‘. > > > > So, out of curiosity, did you test all characters other than null? If - doesn’t work, there is a good chance that no such test has been done, and there is a small hoard of bugs, all the same in there. > > Good point. Objcopy in bfd/binary.c creates symbol names this way: > > for (p = buf; *p; p++) > if (! ISALNUM (*p)) > *p = '_'; > > We should do the same in intelmic-mkoffload.c. I will prepare a patch. gcc/ * config/i386/intelmic-mkoffload.c (prepare_target_image): Handle all non-alphanumeric characters in the symbol name. Regtested on x86_64-linux. OK for trunk? OK for gcc-5-branch? diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c index 49e99e8..4a7812c 100644 --- a/gcc/config/i386/intelmic-mkoffload.c +++ b/gcc/config/i386/intelmic-mkoffload.c @@ -453,17 +453,18 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) fork_execute (objcopy_argv[0], CONST_CAST (char **, objcopy_argv), false); /* Objcopy has created symbols, containing the input file name with - special characters replaced with '_'. We are going to rename these - new symbols. */ + non-alphanumeric characters replaced by underscores. + We are going to rename these new symbols. */ size_t symbol_name_len = strlen (target_so_filename); char *symbol_name = XALLOCAVEC (char, symbol_name_len + 1); - for (size_t i = 0; i <= symbol_name_len; i++) + for (size_t i = 0; i < symbol_name_len; i++) { char c = target_so_filename[i]; - if (c == '/' || c == '.' || c == '-') + if (!ISALNUM (c)) c = '_'; symbol_name[i] = c; } + symbol_name[symbol_name_len] = '\0'; char *opt_for_objcopy[3]; opt_for_objcopy[0] = XALLOCAVEC (char, sizeof ("_binary__start=") -- Ilya