about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-01-14 00:24:36 +0000
committerUlrich Drepper <drepper@redhat.com>2004-01-14 00:24:36 +0000
commitea4f25a7f9adb67c2a19c48b453ee52fd65a57ed (patch)
treeb6887613d1be5146b86b758a4cb137c301d4d899
parentb177ed2b58d4db52e9dac00ab6575213817cd9ea (diff)
downloadglibc-ea4f25a7f9adb67c2a19c48b453ee52fd65a57ed.tar.gz
glibc-ea4f25a7f9adb67c2a19c48b453ee52fd65a57ed.tar.xz
glibc-ea4f25a7f9adb67c2a19c48b453ee52fd65a57ed.zip
Update.
2004-01-13  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/x86_64/dl-machine.h: Include <tls.h>.

	* elf/rtld.c (_dl_start_final): Initialze __libc_stack_end here.
	* sysdeps/generic/dl-sysdep.c: Define __libc_stack_end with
	rtld_hidden_def and move into .data.rel.ro section.
	* sysdeps/generic/ldsodefs.h: Declare __libc_stack_end with
	rtld_hidden_proto.
	* sysdeps/generic/libc-start.c: Only initialize __libc_stack_end here
	if !SHARED.

	* sysdeps/unix/sysv/linux/dl-execstack.c
	(_dl_make_stack_executable): Move common code in front.  Use
	__builtin_expect.
-rw-r--r--ChangeLog16
-rw-r--r--elf/rtld.c3
-rw-r--r--sysdeps/generic/dl-sysdep.c5
-rw-r--r--sysdeps/generic/ldsodefs.h8
-rw-r--r--sysdeps/generic/libc-start.c7
5 files changed, 34 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d7fe8099b..3d9fd9660e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,25 @@
+2004-01-13  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/x86_64/dl-machine.h: Include <tls.h>.
+
+	* elf/rtld.c (_dl_start_final): Initialze __libc_stack_end here.
+	* sysdeps/generic/dl-sysdep.c: Define __libc_stack_end with
+	rtld_hidden_def and move into .data.rel.ro section.
+	* sysdeps/generic/ldsodefs.h: Declare __libc_stack_end with
+	rtld_hidden_proto.
+	* sysdeps/generic/libc-start.c: Only initialize __libc_stack_end here
+	if !SHARED.
+
 2004-01-13  Richard Henderson  <rth@redhat.com>
 
 	* sysdeps/unix/sysv/linux/alpha/rt_sigaction.S: Fix typo.
 
 2004-01-13  Ulrich Drepper  <drepper@redhat.com>
 
+	* sysdeps/unix/sysv/linux/dl-execstack.c
+	(_dl_make_stack_executable): Move common code in front.  Use
+	__builtin_expect.
+
 	* sysdeps/unix/sysv/linux/dl-execstack.c: Change interface.  Add
 	challenge for caller.
 	* sysdeps/generic/ldsodefs.h: Change declaration and type of hook
diff --git a/elf/rtld.c b/elf/rtld.c
index 4273a6fb07..91723ccb77 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -253,6 +253,9 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
   HP_TIMING_NOW (GL(dl_cpuclock_offset));
 #endif
 
+  /* Initialize the stack end variable.  */
+  __libc_stack_end = __builtin_frame_address (0);
+
   /* Call the OS-dependent function to set up life so we can do things like
      file access.  It will call `dl_main' (below) to do all the real work
      of the dynamic linker, and then unwind our frame and run the user
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 53b9ea233c..5ec063323f 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -1,5 +1,5 @@
 /* Operating system support for run-time dynamic linker.  Generic Unix version.
-   Copyright (C) 1995-1998, 2000-2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -53,7 +53,8 @@ INTVARDEF(__libc_enable_secure)
 int __libc_multiple_libcs = 0;	/* Defining this here avoids the inclusion
 				   of init-first.  */
 /* This variable contains the lowest stack address ever used.  */
-void *__libc_stack_end;
+void *__libc_stack_end __attribute__ ((section (".data.rel.ro")));
+rtld_hidden_def(__libc_stack_end)
 static ElfW(auxv_t) *_dl_auxv;
 
 #ifndef DL_FIND_ARG_COMPONENTS
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 852cf51280..f511c5d36f 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -456,6 +456,14 @@ extern void **_dl_initial_error_catch_tsd (void) __attribute__ ((const))
 extern int _dl_make_stack_executable (void **stack_endp) internal_function;
 rtld_hidden_proto (_dl_make_stack_executable)
 
+/* Variable pointing to the end of the stack (or close to it).  This value
+   must be constant over the runtime of the application.  Some programs
+   might use the variable which results in copy relocations on some
+   platforms.  But this does not matter, ld.so can always use the local
+   copy.  */
+extern void *__libc_stack_end;
+rtld_hidden_proto (__libc_stack_end)
+
 /* Parameters passed to the dynamic linker.  */
 extern int _dl_argc attribute_hidden;
 extern char **_dl_argv;
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index e297b0a424..716bbc7018 100644
--- a/sysdeps/generic/libc-start.c
+++ b/sysdeps/generic/libc-start.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -105,10 +105,11 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
 
   INIT_ARGV_and_ENVIRON;
 
-  /* Store the lowest stack address.  */
+#ifndef SHARED
+  /* Store the lowest stack address.  This is done in ld.so if this is
+     the code for the DSO.  */
   __libc_stack_end = stack_end;
 
-#ifndef SHARED
 # ifdef HAVE_AUX_VECTOR
   /* First process the auxiliary vector since we need to find the
      program header to locate an eventually present PT_TLS entry.  */