]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Delay initialization of CPU features struct in static binaries
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Wed, 31 May 2017 01:08:32 +0000 (06:38 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Wed, 31 May 2017 01:08:33 +0000 (06:38 +0530)
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.

ChangeLog
csu/libc-start.c
sysdeps/unix/sysv/linux/aarch64/libc-start.c
sysdeps/x86/libc-start.c

index 876244a00a0df8170b6094b81259e52face34ffb..859f582c3ac9b5d0b5d53028fc7e4e7229234c68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-05-31  Siddhesh Poyarekar  <siddhesh@sourceware.org>
+
+       * 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.
+
 2017-05-30  Dennis Wölfing  <denniswoelfing@gmx.de>
            Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
 
index 9a56dcbbaeb7ef85c495b4df9ab1d0b13454c043..c2dd1593eb1f54a5bac77b10b711464849a4e693 100644 (file)
@@ -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 ();
 
index a5babd49ea9c74467ca3f0a9f45cb3c0e3ef7681..089a728a87e8ffd8e375dd34bd996f2d6c25caf9 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <csu/libc-start.c>
-# else
-/* The main work is done in the generic function.  */
-# define LIBC_START_DISABLE_INLINE
-# define LIBC_START_MAIN generic_start_main
-# include <csu/libc-start.c>
+#ifndef SHARED
+# include <ldsodefs.h>
 # include <cpu-features.c>
 
 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 <csu/libc-start.c>
index 9a56adc3ece0d18903889ad27d5a0f322e41722e..e11b490f5c5cb93ff3384bdae3c718f5e5335934 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <csu/libc-start.c>
-# else
-/* The main work is done in the generic function.  */
-# define LIBC_START_DISABLE_INLINE
-# define LIBC_START_MAIN generic_start_main
-# include <csu/libc-start.c>
+#ifndef SHARED
+#include <ldsodefs.h>
 # include <cpu-features.h>
 # include <cpu-features.c>
 
 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 <csu/libc-start.c>