aboutsummaryrefslogtreecommitdiff
path: root/csu/elf-init.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-11-24 11:17:06 -0800
committerUlrich Drepper <drepper@redhat.com>2009-11-24 11:17:06 -0800
commit1c3c269b55c84c29ec1e2c70f122c5e33fef4257 (patch)
tree9f6280c1e3f3a523e40f90f6ff4f8c5c11a995ad /csu/elf-init.c
parentee5a5ba6725ee949483f043cd0cf2a1579b6b509 (diff)
downloadglibc-1c3c269b55c84c29ec1e2c70f122c5e33fef4257.tar
glibc-1c3c269b55c84c29ec1e2c70f122c5e33fef4257.tar.gz
glibc-1c3c269b55c84c29ec1e2c70f122c5e33fef4257.tar.bz2
glibc-1c3c269b55c84c29ec1e2c70f122c5e33fef4257.zip
Fix startup to security-relevant statically linked binaries.
Before the change they crash on startup. Perform IREL relocations earlier to prevent this.
Diffstat (limited to 'csu/elf-init.c')
-rw-r--r--csu/elf-init.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/csu/elf-init.c b/csu/elf-init.c
index 1d2df62ca3..1e3d6d6cd8 100644
--- a/csu/elf-init.c
+++ b/csu/elf-init.c
@@ -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;