This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Move DONT_USE_BOOTSTRAP_MAP defininition to dl-machine.h


Hi!

__attribute__((visibility("hidden"))) does not guarantee no .got
references on all arches (well, only on the few where there are suitable
relocations etc.).
Current glibc e.g. segfaults on Alpha, certainly will not work on SPARC
until GOTOFF like relocs are added, etc.
IMHO it is best to move the definition to sysdep header as this
is something that can be known on a per-arch basis.

2002-08-23  Jakub Jelinek  <jakub@redhat.com>

	* elf/rtld.c (DONT_USE_BOOTSTRAP_MAP): Don't define here.
	Rename to RTLD_DONT_USE_BOOTSTRAP_MAP.
	* sysdeps/i386/dl-machine.h (RTLD_DONT_USE_BOOTSTRAP_MAP): Define.

--- libc/elf/rtld.c.jj	Thu Aug 22 06:21:50 2002
+++ libc/elf/rtld.c	Thu Aug 22 18:47:34 2002
@@ -125,15 +125,14 @@ TLS_INIT_HELPER
 
 /* Before ld.so is relocated we must not access variables which need
    relocations.  This means variables which are exported.  Variables
-   declared as static are fine.  If we can mark a variable hidden this
-   is fine, too.  The latter is impotant here.  We can avoid setting
-   up a temporary link map for ld.so if we can mark _rtld_global as
-   hidden.  */
-#ifdef HAVE_HIDDEN
-# define DONT_USE_BOOTSTRAP_MAP	1
-#endif
+   declared as static are fine.  If we can mark a variable hidden and
+   the accesses won't go through .got, it is fine, too.
+   The latter is impotant here.  We can avoid setting up a temporary
+   link map for ld.so if we can mark _rtld_global as hidden.
+   Define RTLD_DONT_USE_BOOTSTRAP_MAP in dl-machine.h if this is the
+   case.  */
 
-#ifdef DONT_USE_BOOTSTRAP_MAP
+#ifdef RTLD_DONT_USE_BOOTSTRAP_MAP
 static ElfW(Addr) _dl_start_final (void *arg);
 #else
 static ElfW(Addr) _dl_start_final (void *arg,
@@ -156,12 +155,12 @@ RTLD_START
 #endif
 
 /* This is the second half of _dl_start (below).  It can be inlined safely
-   under DONT_USE_BOOTSTRAP_MAP, where it is careful not to make any GOT
-   references.  When the tools don't permit us to avoid using a GOT entry
-   for _dl_rtld_global (no attribute_hidden support), we must make sure
-   this function is not inlined (see below).  */
+   under RTLD_DONT_USE_BOOTSTRAP_MAP, where it is careful not to make any
+   GOT references.  When the tools don't permit us to avoid using a GOT
+   entry for _dl_rtld_global (no attribute_hidden support), we must make
+   sure this function is not inlined (see below).  */
 
-#ifdef DONT_USE_BOOTSTRAP_MAP
+#ifdef RTLD_DONT_USE_BOOTSTRAP_MAP
 static inline ElfW(Addr) __attribute__ ((always_inline))
 _dl_start_final (void *arg)
 #else
@@ -184,7 +183,7 @@ _dl_start_final (void *arg, struct link_
     }
 
   /* Transfer data about ourselves to the permanent link_map structure.  */
-#ifndef DONT_USE_BOOTSTRAP_MAP
+#ifndef RTLD_DONT_USE_BOOTSTRAP_MAP
   GL(dl_rtld_map).l_addr = bootstrap_map_p->l_addr;
   GL(dl_rtld_map).l_ld = bootstrap_map_p->l_ld;
   memcpy (GL(dl_rtld_map).l_info, bootstrap_map_p->l_info,
@@ -196,7 +195,7 @@ _dl_start_final (void *arg, struct link_
   GL(dl_rtld_map).l_map_start = (ElfW(Addr)) _begin;
   GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
   /* Copy the TLS related data if necessary.  */
-#if USE_TLS && !defined DONT_USE_BOOTSTRAP_MAP
+#if USE_TLS && !defined RTLD_DONT_USE_BOOTSTRAP_MAP
 # ifdef HAVE___THREAD
   assert (bootstrap_map_p->l_tls_modid != 0);
 # else
@@ -247,7 +246,7 @@ _dl_start_final (void *arg, struct link_
 static ElfW(Addr) __attribute_used__ internal_function
 _dl_start (void *arg)
 {
-#ifdef DONT_USE_BOOTSTRAP_MAP
+#ifdef RTLD_DONT_USE_BOOTSTRAP_MAP
 # define bootstrap_map GL(dl_rtld_map)
 #else
   struct link_map bootstrap_map;
@@ -279,7 +278,7 @@ _dl_start (void *arg)
      know it is available.  We do not have to clear the memory if we
      do not have to use the temporary bootstrap_map.  Global variables
      are initialized to zero by default.  */
-#ifndef DONT_USE_BOOTSTRAP_MAP
+#ifndef RTLD_DONT_USE_BOOTSTRAP_MAP
 # ifdef HAVE_BUILTIN_MEMSET
   __builtin_memset (bootstrap_map.l_info, '\0', sizeof (bootstrap_map.l_info));
 # else
@@ -298,7 +297,7 @@ _dl_start (void *arg)
   elf_get_dynamic_info (&bootstrap_map);
 
 #if USE_TLS
-# if !defined HAVE___THREAD && !defined DONT_USE_BOOTSTRAP_MAP
+# if !defined HAVE___THREAD && !defined RTLD_DONT_USE_BOOTSTRAP_MAP
   /* Signal that we have not found TLS data so far.  */
   bootstrap_map.l_tls_modid = 0;
 # endif
@@ -426,7 +425,7 @@ _dl_start (void *arg)
      function, that way the compiler cannot put accesses to the GOT
      before ELF_DYNAMIC_RELOCATE.  */
   {
-#ifdef DONT_USE_BOOTSTRAP_MAP
+#ifdef RTLD_DONT_USE_BOOTSTRAP_MAP
     ElfW(Addr) entry = _dl_start_final (arg);
 #else
     ElfW(Addr) entry = _dl_start_final (arg, &bootstrap_map);
--- libc/sysdeps/i386/dl-machine.h.jj	Fri Aug  9 04:02:54 2002
+++ libc/sysdeps/i386/dl-machine.h	Thu Aug 22 18:48:06 2002
@@ -196,6 +196,16 @@ _dl_runtime_profile:\n\
    where the dynamic linker should not map anything.  */
 #define ELF_MACHINE_USER_ADDRESS_MASK	0xf8000000UL
 
+/* Before ld.so is relocated we must not access variables which need
+   relocations.  This means variables which are exported.  Variables
+   declared as static are fine.  If we can mark a variable hidden this
+   is fine, too.  The latter is impotant here.  We can avoid setting
+   up a temporary link map for ld.so if we can mark _rtld_global as
+   hidden.  */
+#ifdef HAVE_VISIBILITY_ATTRIBUTE
+# define RTLD_DONT_USE_BOOTSTRAP_MAP	1
+#endif
+
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]