]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix startup to security-relevant statically linked binaries.
authorUlrich Drepper <drepper@redhat.com>
Tue, 24 Nov 2009 19:17:06 +0000 (11:17 -0800)
committerAndreas Schwab <schwab@redhat.com>
Wed, 25 Nov 2009 13:02:17 +0000 (14:02 +0100)
Before the change they crash on startup.  Perform IREL relocations
earlier to prevent this.
(cherry picked from commit 1c3c269b55c84c29ec1e2c70f122c5e33fef4257)

ChangeLog
csu/elf-init.c
csu/libc-start.c

index e0fd11c15e3ab852a369e99594cce069b1d6e811..3cae5d1cf150ebcc6e8298f6c52ebb270025fe4d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-11-24  Ulrich Drepper  <drepper@redhat.com>
+
+       * csu/elf-init.c (__libc_csu_irel): New function.  Code to perform
+       irel relocations split out from...
+       (__libc_csu_init): ...here.
+       * csu/libc-start.c [!SHARED]: Call __libc_csu_irel early.
+
 2009-11-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #10162]
index 1d2df62ca30adaaff01dc97d536ac0e0a33006bd..1e3d6d6cd8f7b916bbb127eea50a84fa2e0dfec2 100644 (file)
@@ -72,15 +72,14 @@ extern void _fini (void);
 /* These functions are passed to __libc_start_main by the startup code.
    These get statically linked into each program.  For dynamically linked
    programs, this module will come from libc_nonshared.a and differs from
-   the libc.a module in that it doesn't call the preinit array.  */
+   the libc.a module in that it doesn't call the preinit array and performs
+   explicit IREL{,A} relocations.  */
 
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
-  /* For dynamically linked executables the preinit array is executed by
-     the dynamic linker (before initializing any shared object.  */
 
 #ifndef LIBC_NONSHARED
+void
+__libc_csu_irel (void)
+{
 # ifdef USE_MULTIARCH
 #  ifdef ELF_MACHINE_IRELA
   {
@@ -98,7 +97,17 @@ __libc_csu_init (int argc, char **argv, char **envp)
   }
 #  endif
 # endif
+}
+#endif
 
+
+void
+__libc_csu_init (int argc, char **argv, char **envp)
+{
+  /* For dynamically linked executables the preinit array is executed by
+     the dynamic linker (before initializing any shared object.  */
+
+#ifndef LIBC_NONSHARED
   /* For static executables, preinit happens right before init.  */
   {
     const size_t size = __preinit_array_end - __preinit_array_start;
index 80b672f88d87735ffa26a447e0c810ffe35d00b4..dc7ca55f098a650d367838685084a5571c047220 100644 (file)
@@ -24,6 +24,9 @@
 #include <bp-sym.h>
 
 extern void __libc_init_first (int argc, char **argv, char **envp);
+#ifndef SHARED
+extern void __libc_csu_irel (void);
+#endif
 
 extern int __libc_multiple_libcs;
 
@@ -134,6 +137,9 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
     }
 # endif
 
+  /* Performe IREL{,A} relocations.  */
+  __libc_csu_irel ();
+
   /* Initialize the thread library at least a bit since the libgcc
      functions are using thread functions if these are available and
      we need to setup errno.  */