about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-01 01:33:04 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-01 01:33:04 +0000
commit5688da55372193e5941f0240e6ea759d28483970 (patch)
tree07e201b5db41088611a28d339926c7a953fa7391 /elf
parenta204ea3607d148c7b83dec5b54496762a99699d8 (diff)
downloadglibc-5688da55372193e5941f0240e6ea759d28483970.tar.gz
glibc-5688da55372193e5941f0240e6ea759d28483970.tar.xz
glibc-5688da55372193e5941f0240e6ea759d28483970.zip
Update.
	* sysdeps/generic/ldsodefs.h: Add _dl_load_lock, _dl_lazy,
	_dl_dynamic_weak, _dl_fpu_control, _dl_cpuclock_offset, and
	_dl_debug_fd to rtld_global.
	* elf/Versions: Likewise.
	* elf/dl-close.c: Likewise.
	* elf/dl-iteratephdr.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-misc.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-support.c: Likewise.
	* elf/do-lookup.h: Likewise.
	* elf/rtld.c: Likewise.
	* sysdeps/generic/dl-cache.c: Likewise.
	* sysdeps/generic/dl-sysdep.c: Likewise.
	* sysdeps/ia64/Versions: Likewise.
	* sysdeps/unix/clock_gettime.c: Likewise.
	* sysdeps/unix/clock_settime.c: Likewise.
	* sysdeps/unix/sysv/linux/init-first.c: Likewise.
	* sysdeps/sparc/Versions: Removed.
	* sysdeps/i386/i686/Versions : Removed.
	* sysdeps/x86_64/Versions: Removed.
	* configure.in: Define HAVE_PROTECTED if .protected is available.
	* config.h.in: Add entry for HAVE_PROTECTED.

2002-01-31  Jakub Jelinek  <jakub@redhat.com.

	* sysdeps/alpha/dl-machine.h: Move global variables for SHARED
	code in struct _rtld_global.  Export this struct, remove all
	exports for the signal variables.
	* sysdeps/arm/dl-machine: Likewise.
	* sysdeps/generic/dl-origin: Likewise.
	* sysdeps/generic/dl-sysdep: Likewise.
	* sysdeps/generic/dl-cache: Likewise.
	* sysdeps/hppa/dl-fptr: Likewise.
	* sysdeps/hppa/dl-machine: Likewise.
	* sysdeps/cris/dl-machine: Likewise.
	* sysdeps/i386/dl-machine: Likewise.
	* sysdeps/ia64/dl-machine: Likewise.
	* sysdeps/m68k/dl-machine: Likewise.
	* sysdeps/mach/hurd/dl-sysdep: Likewise.
	* sysdeps/mips/mips64/dl-machine: Likewise.
	* sysdeps/mips/dl-machine: Likewise.
	* sysdeps/powerpc/elf/libc-start: Likewise.
	* sysdeps/powerpc/dl-machine: Likewise.
	* sysdeps/powerpc/dl-start: Likewise.
	* sysdeps/sparc/sparc32/dl-machine: Likewise.
	* sysdeps/sparc/sparc64/dl-machine: Likewise.
	* sysdeps/sh/dl-machine: Likewise.
	* sysdeps/s390/s390-32/dl-machine: Likewise.
	* sysdeps/s390/s390-64/dl-machine: Likewise.
	* sysdeps/unix/sysv/aix/libc-start: Likewise.
	* sysdeps/unix/sysv/aix/start-libc: Likewise.
	* sysdeps/unix/sysv/linux/ia64/dl-static: Likewise.
	* sysdeps/unix/sysv/linux/m68k/getpagesize: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/getpagesize: Likewise.
	* sysdeps/x86_64/dl-machine: Likewise.

2002-01-31  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'elf')
-rw-r--r--elf/Versions10
-rw-r--r--elf/dl-close.c6
-rw-r--r--elf/dl-iteratephdr.c4
-rw-r--r--elf/dl-lookup.c4
-rw-r--r--elf/dl-misc.c10
-rw-r--r--elf/dl-open.c6
-rw-r--r--elf/dl-support.c6
-rw-r--r--elf/do-lookup.h2
-rw-r--r--elf/rtld.c63
9 files changed, 55 insertions, 56 deletions
diff --git a/elf/Versions b/elf/Versions
index 5c8da22843..af4f4b84a8 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -30,9 +30,6 @@ libc {
 
 ld {
   GLIBC_2.0 {
-    # global variables
-    _dl_debug_fd;
-
     # Those are in the dynamic linker, but used by libc.so.
     __libc_enable_secure; _dl_catch_error; _dl_check_all_versions;
     _dl_debug_initialize; _dl_debug_state;
@@ -48,20 +45,17 @@ ld {
   }
   GLIBC_2.1 {
     # global variables
-    _dl_fpu_control; __libc_stack_end;
+    __libc_stack_end;
 
     # functions used in other libraries
     _dl_start_profile; _dl_mcount; _dl_unload_cache;
   }
   GLIBC_2.1.1 {
-    # global variables
-    _dl_lazy;
-
     # functions used in other libraries
     _dl_dst_count; _dl_dst_substitute;
   }
   GLIBC_2.2 {
-    _dl_init; _dl_load_lock; _dl_argv; _dl_check_map_versions;
+    _dl_init; _dl_argv; _dl_check_map_versions;
 
     # variables used elsewhere
     _dl_out_of_memory;
diff --git a/elf/dl-close.c b/elf/dl-close.c
index cece96b7fb..65de9e7809 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -57,7 +57,7 @@ _dl_close (void *_map)
     _dl_signal_error (0, map->l_name, NULL, N_("shared object not open"));
 
   /* Acquire the lock.  */
-  __libc_lock_lock_recursive (_dl_load_lock);
+  __libc_lock_lock_recursive (GL(dl_load_lock));
 
   /* Decrement the reference count.  */
   if (map->l_opencount > 1 || map->l_type != lt_loaded)
@@ -70,7 +70,7 @@ _dl_close (void *_map)
       /* One decrement the object itself, not the dependencies.  */
       --map->l_opencount;
 
-      __libc_lock_unlock_recursive (_dl_load_lock);
+      __libc_lock_unlock_recursive (GL(dl_load_lock));
       return;
     }
 
@@ -298,7 +298,7 @@ _dl_close (void *_map)
   free (list);
 
   /* Release the lock.  */
-  __libc_lock_unlock_recursive (_dl_load_lock);
+  __libc_lock_unlock_recursive (GL(dl_load_lock));
 }
 
 
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index e2a5d2a753..3145e382aa 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -32,7 +32,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
   int ret = 0;
 
   /* Make sure we are alone.  */
-  __libc_lock_lock_recursive (_dl_load_lock);
+  __libc_lock_lock_recursive (GL(dl_load_lock));
 
   for (l = GL(dl_loaded); l != NULL; l = l->l_next)
     {
@@ -49,7 +49,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
     }
 
   /* Release the lock.  */
-  __libc_lock_unlock_recursive (_dl_load_lock);
+  __libc_lock_unlock_recursive (GL(dl_load_lock));
 
   return ret;
 }
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index f10ff4739d..695ce54b4e 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -94,7 +94,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
     return 0;
 
   /* Make sure nobody can unload the object while we are at it.  */
-  __libc_lock_lock_recursive (_dl_load_lock);
+  __libc_lock_lock_recursive (GL(dl_load_lock));
 
   /* Determine whether UNDEF_MAP already has a reference to MAP.  First
      look in the normal dependencies.  */
@@ -180,7 +180,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
 
  out:
   /* Release the lock.  */
-  __libc_lock_unlock_recursive (_dl_load_lock);
+  __libc_lock_unlock_recursive (GL(dl_load_lock));
 
   return result;
 }
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index a96689edf7..d4d9d13e03 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -1,5 +1,5 @@
 /* Miscellaneous support functions for dynamic linker
-   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,1999,2000,2001,2002 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
@@ -80,10 +80,6 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
 }
 
 
-/* Descriptor to write debug messages to.  */
-int _dl_debug_fd = 2;
-
-
 /* Bare-bone printf implementation.  This function only knows about
    the formats and flags needed and can handle only up to 64 stripes in
    the output.  */
@@ -250,7 +246,7 @@ _dl_debug_printf (const char *fmt, ...)
   va_list arg;
 
   va_start (arg, fmt);
-  _dl_debug_vdprintf (_dl_debug_fd, 1, fmt, arg);
+  _dl_debug_vdprintf (GL(dl_debug_fd), 1, fmt, arg);
   va_end (arg);
 }
 
@@ -262,7 +258,7 @@ _dl_debug_printf_c (const char *fmt, ...)
   va_list arg;
 
   va_start (arg, fmt);
-  _dl_debug_vdprintf (_dl_debug_fd, -1, fmt, arg);
+  _dl_debug_vdprintf (GL(dl_debug_fd), -1, fmt, arg);
   va_end (arg);
 }
 
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 2f82e4cf40..56b6cbb319 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -259,7 +259,7 @@ dl_open_worker (void *a)
 #endif
 
   /* Only do lazy relocation if `LD_BIND_NOW' is not set.  */
-  lazy = (mode & RTLD_BINDING_MASK) == RTLD_LAZY && _dl_lazy;
+  lazy = (mode & RTLD_BINDING_MASK) == RTLD_LAZY && GL(dl_lazy);
 
   /* Relocate the objects loaded.  We do this in reverse order so that copy
      relocs of earlier objects overwrite the data written by later objects.  */
@@ -400,7 +400,7 @@ _dl_open (const char *file, int mode, const void *caller)
     _dl_signal_error (EINVAL, file, NULL, N_("invalid mode for dlopen()"));
 
   /* Make sure we are alone.  */
-  __libc_lock_lock_recursive (_dl_load_lock);
+  __libc_lock_lock_recursive (GL(dl_load_lock));
 
   args.file = file;
   args.mode = mode;
@@ -414,7 +414,7 @@ _dl_open (const char *file, int mode, const void *caller)
 #endif
 
   /* Release the lock.  */
-  __libc_lock_unlock_recursive (_dl_load_lock);
+  __libc_lock_unlock_recursive (GL(dl_load_lock));
 
   if (errstring)
     {
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 0efbcc4cb6..b78b79d6d9 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -27,6 +27,7 @@
 #include <ldsodefs.h>
 #include <dl-machine.h>
 #include <bits/libc-lock.h>
+#include <dl-cache.h>
 #include <dl-librecon.h>
 #include <unsecvars.h>
 #include <hp-timing.h>
@@ -119,6 +120,11 @@ struct r_search_path_elem *_dl_init_all_dirs;
 /* The object to be initialized first.  */
 struct link_map *_dl_initfirst;
 
+/* Descriptor to write debug messages to.  */
+int _dl_debug_fd = STDERR_FILENO;
+
+int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
+
 /* During the program run we must not modify the global data of
    loaded shared object simultanously in two threads.  Therefore we
    protect `_dl_open' and `_dl_close' in dl-close.c.
diff --git a/elf/do-lookup.h b/elf/do-lookup.h
index 65f7b02a20..18d1ab5bfe 100644
--- a/elf/do-lookup.h
+++ b/elf/do-lookup.h
@@ -160,7 +160,7 @@ FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref,
 	    {
 	    case STB_WEAK:
 	      /* Weak definition.  Use this value if we don't find another.  */
-	      if (__builtin_expect (_dl_dynamic_weak, 0))
+	      if (__builtin_expect (GL(dl_dynamic_weak), 0))
 		{
 		  if (! result->s)
 		    {
diff --git a/elf/rtld.c b/elf/rtld.c
index 050d7fae8a..e4c2c6e0ad 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -33,6 +33,8 @@
 #include "dynamic-link.h"
 #include "dl-librecon.h"
 #include <unsecvars.h>
+#include <dl-cache.h>
+#include <dl-procinfo.h>
 
 #include <assert.h>
 
@@ -58,25 +60,6 @@ static void process_envvars (enum mode *modep);
 int _dl_argc;
 char **_dl_argv;
 unsigned int _dl_skip_args;	/* Nonzero if we were run directly.  */
-fpu_control_t _dl_fpu_control = _FPU_DEFAULT;
-int _dl_lazy = 1;
-/* XXX I know about at least one case where we depend on the old weak
-   behavior (it has to do with librt).  Until we get DSO groups implemented
-   we have to make this the default.  Bummer. --drepper  */
-#if 0
-int _dl_dynamic_weak;
-#else
-int _dl_dynamic_weak = 1;
-#endif
-
-/* During the program run we must not modify the global data of
-   loaded shared object simultanously in two threads.  Therefore we
-   protect `_dl_open' and `_dl_close' in dl-close.c.
-
-   This must be a recursive lock since the initializer function of
-   the loaded object might as well require a call to this function.
-   At this time it is not anymore a problem to modify the tables.  */
-__libc_lock_define_initialized_recursive (, _dl_load_lock)
 
 /* Set nonzero during loading and initialization of executable and
    libraries, cleared before the executable's entry point runs.  This
@@ -89,7 +72,26 @@ int _dl_starting_up;
 
 /* This is the structure which defines all variables global to ld.so
    (except those which cannot be added for some reason).  */
-struct rtld_global _rtld_global;
+struct rtld_global _rtld_global =
+  {
+    ._dl_debug_fd = STDERR_FILENO,
+#if 1
+    /* XXX I know about at least one case where we depend on the old
+       weak behavior (it has to do with librt).  Until we get DSO
+       groups implemented we have to make this the default.
+       Bummer. --drepper  */
+    ._dl_dynamic_weak = 1,
+#endif
+    ._dl_lazy = 1,
+    ._dl_fpu_control = _FPU_DEFAULT,
+    ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
+    ._dl_hwcap_mask = HWCAP_IMPORTANT,
+    ._dl_load_lock = _LIBC_LOCK_RECURSIVE_INITIALIZER
+  };
+/* There must only be the definition in ld.so itself.  */
+#ifdef HAVE_PROTECTED
+asm (".protected _rtld_global");
+#endif
 
 
 static void dl_main (const ElfW(Phdr) *phdr,
@@ -418,7 +420,7 @@ dl_main (const ElfW(Phdr) *phdr,
 	if (! strcmp (_dl_argv[1], "--list"))
 	  {
 	    mode = list;
-	    _dl_lazy = -1;	/* This means do no dependency analysis.  */
+	    GL(dl_lazy) = -1;	/* This means do no dependency analysis.  */
 
 	    ++_dl_skip_args;
 	    --_dl_argc;
@@ -941,13 +943,13 @@ of this helper program; chances are you did not intend to run this program.\n\
       else
 	{
 	  /* If LD_WARN is set warn about undefined symbols.  */
-	  if (_dl_lazy >= 0 && GL(dl_verbose))
+	  if (GL(dl_lazy) >= 0 && GL(dl_verbose))
 	    {
 	      /* We have to do symbol dependency testing.  */
 	      struct relocate_args args;
 	      struct link_map *l;
 
-	      args.lazy = _dl_lazy;
+	      args.lazy = GL(dl_lazy);
 
 	      l = GL(dl_loaded);
 	      while (l->l_next)
@@ -1142,7 +1144,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 #endif
 
     /* If we are profiling we also must do lazy reloaction.  */
-    _dl_lazy |= consider_profiling;
+    GL(dl_lazy) |= consider_profiling;
 
     l = GL(dl_loaded);
     while (l->l_next)
@@ -1163,7 +1165,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	  }
 
 	if (l != &GL(dl_rtld_map))
-	  _dl_relocate_object (l, l->l_scope, _dl_lazy, consider_profiling);
+	  _dl_relocate_object (l, l->l_scope, GL(dl_lazy), consider_profiling);
 
 	l = l->l_prev;
       }
@@ -1327,6 +1329,7 @@ process_dl_debug (const char *dl_debug)
 		&& debopts[cnt].name[len] == '\0')
 	      {
 		GL(dl_debug_mask) |= debopts[cnt].mask;
+		any_debug = 1;
 		break;
 	      }
 
@@ -1428,7 +1431,7 @@ process_envvars (enum mode *modep)
 	  /* Do we bind early?  */
 	  if (memcmp (envline, "BIND_NOW", 8) == 0)
 	    {
-	      _dl_lazy = envline[9] == '\0';
+	      GL(dl_lazy) = envline[9] == '\0';
 	      break;
 	    }
 	  if (memcmp (envline, "BIND_NOT", 8) == 0)
@@ -1471,7 +1474,7 @@ process_envvars (enum mode *modep)
 	    }
 
 	  if (memcmp (envline, "DYNAMIC_WEAK", 12) == 0)
-	    _dl_dynamic_weak = 1;
+	    GL(dl_dynamic_weak) = 1;
 	  break;
 
 	case 14:
@@ -1553,10 +1556,10 @@ process_envvars (enum mode *modep)
       *--startp = '.';
       startp = memcpy (startp - name_len, debug_output, name_len);
 
-      _dl_debug_fd = __open (startp, flags, DEFFILEMODE);
-      if (_dl_debug_fd == -1)
+      GL(dl_debug_fd) = __open (startp, flags, DEFFILEMODE);
+      if (GL(dl_debug_fd) == -1)
 	/* We use standard output if opening the file failed.  */
-	_dl_debug_fd = STDOUT_FILENO;
+	GL(dl_debug_fd) = STDOUT_FILENO;
     }
 }