This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable


On Tue, May 10, 2016 at 9:50 AM, H.J. Lu <hongjiu.lu@intel.com> 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.


-- 
H.J.
From f8cbec51d151fe1cd9cbbecb6db391734d50e71d Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]