* [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable
@ 2016-05-10 16:50 H.J. Lu
2016-05-13 15:12 ` H.J. Lu
0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2016-05-10 16:50 UTC (permalink / raw)
To: GNU C Library
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.
---
sysdeps/i386/dl-machine.h | 2 ++
sysdeps/x86_64/dl-machine.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 130bcf5..9c34a90 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -237,7 +237,9 @@ dl_platform_init (void)
/* Avoid an empty string which would disturb us. */
GLRO(dl_platform) = NULL;
+#ifdef SHARED
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..6998d0b 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -224,7 +224,9 @@ dl_platform_init (void)
/* Avoid an empty string which would disturb us. */
GLRO(dl_platform) = NULL;
+#ifdef SHARED
init_cpu_features (&GLRO(dl_x86_cpu_features));
+#endif
}
static inline ElfW(Addr)
--
2.5.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable
2016-05-10 16:50 [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable H.J. Lu
@ 2016-05-13 15:12 ` H.J. Lu
0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2016-05-13 15:12 UTC (permalink / raw)
To: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
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.
[-- Attachment #2: 0001-Call-init_cpu_features-only-if-SHARED-is-defined.patch --]
[-- Type: text/x-patch, Size: 1670 bytes --]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-13 15:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 16:50 [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable H.J. Lu
2016-05-13 15:12 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).