This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 10 May 2016 09:50:04 -0700
- Subject: [PATCH] [BZ #20072] x86 init_cpu_features is called twice in static executable
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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