From patchwork Fri May 13 15:12:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 12237 Received: (qmail 100432 invoked by alias); 13 May 2016 15:12:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 100408 invoked by uid 89); 13 May 2016 15:12:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=hongjiuluintelcom, hongjiu.lu@intel.com, H*c:sk:001a11c X-HELO: mail-qg0-f65.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=QgUDAf5TokY6GYg4ZfcLt1dFdXAxIZdo9vHJrX7eV9k=; b=MHxHwQzfFxgvqhHVn26OErO88dsiD1eo3N23yVMTm01UxFlfvfSXpPV92K9mkx31eg Wq/60V4pYHKDpO2xm2D32wwsimVwlQp6FXuFQN6gkmymjSVZFbqgB4O6A03aqwP967uj f/c3v1DLuHEFrd+oqQ6lov678Q2UvxrC1ESVvqpTyJIvEil7AiOr6XmALye2qpxmrm5Y FmN2O6E8pW/kR538KG5r5ej+I+u5kzq+iaOE+JfGJcEfrikxaLhqu/mgDw5E71Pd2LU9 t5+9LyR/SzskBRPwqvMu98WUDZ24ytvlOyKX5zi/1HyaiAmhUTeKTpChf2zFK4NGnWt8 7dDg== X-Gm-Message-State: AOPr4FU2MoTsas+cGH7fnFW7dlrBQNPSJl8JhqFYpRZ+8D5UxzgGDXaTg+gSqToNP1GVqFqPEsIusByaLhHPOg== MIME-Version: 1.0 X-Received: by 10.140.22.203 with SMTP id 69mr15899499qgn.62.1463152355487; Fri, 13 May 2016 08:12:35 -0700 (PDT) In-Reply-To: <20160510165004.GA13777@intel.com> References: <20160510165004.GA13777@intel.com> Date: Fri, 13 May 2016 08:12:35 -0700 Message-ID: Subject: Re: [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable From: "H.J. Lu" To: GNU C Library On Tue, May 10, 2016 at 9:50 AM, H.J. Lu wrote: > In static executable, since init_cpu_features is called early from > __libc_start_main, there is no need to call it again in dl_platform_init. > > Tested on x86 and x86-64. Any comments, feedbacks? > > H.J. > --- > [BZ #20072] > * sysdeps/i386/dl-machine.h (dl_platform_init): Call > init_cpu_features only if SHARED is defined. > * sysdeps/x86_64/dl-machine.h (dl_platform_init): Likewise. I will check in this revised patch today. From f8cbec51d151fe1cd9cbbecb6db391734d50e71d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 10 May 2016 09:44:30 -0700 Subject: [PATCH] Call init_cpu_features only if SHARED is defined In static executable, since init_cpu_features is called early from __libc_start_main, there is no need to call it again in dl_platform_init. [BZ #20072] * sysdeps/i386/dl-machine.h (dl_platform_init): Call init_cpu_features only if SHARED is defined. * sysdeps/x86_64/dl-machine.h (dl_platform_init): Likewise. --- sysdeps/i386/dl-machine.h | 4 ++++ sysdeps/x86_64/dl-machine.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 130bcf5..4e3968a 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -237,7 +237,11 @@ dl_platform_init (void) /* Avoid an empty string which would disturb us. */ GLRO(dl_platform) = NULL; +#ifdef SHARED + /* init_cpu_features has been called early from __libc_start_main in + static executable. */ init_cpu_features (&GLRO(dl_x86_cpu_features)); +#endif } static inline Elf32_Addr diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 980ca73..ed0c1a8 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -224,7 +224,11 @@ dl_platform_init (void) /* Avoid an empty string which would disturb us. */ GLRO(dl_platform) = NULL; +#ifdef SHARED + /* init_cpu_features has been called early from __libc_start_main in + static executable. */ init_cpu_features (&GLRO(dl_x86_cpu_features)); +#endif } static inline ElfW(Addr) -- 2.5.5