From patchwork Thu May 18 20:07:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 764166 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 3wTMhH5S49z9s4q for ; Fri, 19 May 2017 06:08:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="o/D8RgNR"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=V9oFlwTCODBWlPVReuyPK3G7Td9ugPT Ui8UXuOm2h5OMhXWvQdqhmovtPBp7SEdep5rtGT0KHVZ004xAh4aQizn2j78C3JO ags1PUu0BvymyOiL487SD2Ttb4xMH6hB3QK0WtWF7/2hq4bLFFMHRg4KP4iy0fbX S/juc++bu9MM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=HbSaBZu+xflsWUeQpRzpS2pNln0=; b=o/D8R gNRUrBiWTL89Q6IBloxiUnVvfvBGCtZPKNOM8tn6l1NULK6Xml5ysK9bWPfR+aR7 DNnghRtk4HLEbq/XX1LF2cPXLVAtJ35Wn8HHxZWm+yPA1Ir7UMcnV3V5xY2Wo8qa N61xbMlTpIHNpOfwVzV2ibHZbrL6C9rwW81hs0= Received: (qmail 116923 invoked by alias); 18 May 2017 20:07:44 -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 116858 invoked by uid 89); 18 May 2017 20:07:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy= X-HELO: homiemail-a68.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org Subject: [PATCH 4/5] Delay initialization of CPU features struct in static binaries Date: Fri, 19 May 2017 01:37:17 +0530 Message-Id: <1495138038-32212-5-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1495138038-32212-1-git-send-email-siddhesh@sourceware.org> References: <1495138038-32212-1-git-send-email-siddhesh@sourceware.org> Allow the CPU features structure set up to be overridden by tunables by delaying it to until after tunables are initialized. The initialization is already delayed in dynamically linked glibc, it is only in static binaries that the initialization is set early to allow it to influence IFUNC relocations that happen in libc-start. It is a bit too early however and there is a good place between tunables initialization and IFUNC relocations where this can be done. Verified that this does not regress the testsuite. * csu/libc-start.c [!ARCH_INIT_CPU_FEATURES]: Define ARCH_INIT_CPU_FEATURES. (LIBC_START_MAIN): Call it. * sysdeps/unix/sysv/linux/aarch64/libc-start.c (__libc_start_main): Remove. (ARCH_INIT_CPU_FEATURES): New macro. * sysdeps/x86/libc-start.c (__libc_start_main): Remove. (ARCH_INIT_CPU_FEATURES): New macro. --- csu/libc-start.c | 6 ++++++ sysdeps/unix/sysv/linux/aarch64/libc-start.c | 23 +++++------------------ sysdeps/x86/libc-start.c | 23 +++++------------------ 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/csu/libc-start.c b/csu/libc-start.c index 9a56dcb..c2dd159 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -104,6 +104,10 @@ apply_irel (void) # define MAIN_AUXVEC_PARAM #endif +#ifndef ARCH_INIT_CPU_FEATURES +# define ARCH_INIT_CPU_FEATURES() +#endif + STATIC int LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), int argc, @@ -182,6 +186,8 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), __tunables_init (__environ); + ARCH_INIT_CPU_FEATURES (); + /* Perform IREL{,A} relocations. */ apply_irel (); diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-start.c b/sysdeps/unix/sysv/linux/aarch64/libc-start.c index a5babd4..089a728 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc-start.c +++ b/sysdeps/unix/sysv/linux/aarch64/libc-start.c @@ -16,26 +16,13 @@ License along with the GNU C Library; if not, see . */ -#ifdef SHARED -# include -# else -/* The main work is done in the generic function. */ -# define LIBC_START_DISABLE_INLINE -# define LIBC_START_MAIN generic_start_main -# include +#ifndef SHARED +# include # include extern struct cpu_features _dl_aarch64_cpu_features; -int -__libc_start_main (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), - int argc, char **argv, - __typeof (main) init, - void (*fini) (void), - void (*rtld_fini) (void), void *stack_end) -{ - init_cpu_features (&_dl_aarch64_cpu_features); - return generic_start_main (main, argc, argv, init, fini, rtld_fini, - stack_end); -} +# define ARCH_INIT_CPU_FEATURES() init_cpu_features (&_dl_aarch64_cpu_features) + #endif +#include diff --git a/sysdeps/x86/libc-start.c b/sysdeps/x86/libc-start.c index 9a56adc..e11b490 100644 --- a/sysdeps/x86/libc-start.c +++ b/sysdeps/x86/libc-start.c @@ -15,27 +15,14 @@ License along with the GNU C Library; if not, see . */ -#ifdef SHARED -# include -# else -/* The main work is done in the generic function. */ -# define LIBC_START_DISABLE_INLINE -# define LIBC_START_MAIN generic_start_main -# include +#ifndef SHARED +#include # include # include extern struct cpu_features _dl_x86_cpu_features; -int -__libc_start_main (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), - int argc, char **argv, - __typeof (main) init, - void (*fini) (void), - void (*rtld_fini) (void), void *stack_end) -{ - init_cpu_features (&_dl_x86_cpu_features); - return generic_start_main (main, argc, argv, init, fini, rtld_fini, - stack_end); -} +#define ARCH_INIT_CPU_FEATURES() init_cpu_features (&_dl_x86_cpu_features) + #endif +# include