about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-cache.c17
-rw-r--r--sysdeps/generic/dl-sysdep.c29
-rw-r--r--sysdeps/generic/ldsodefs.h168
-rw-r--r--sysdeps/generic/libc-start.c6
-rw-r--r--sysdeps/i386/dl-machine.h18
-rw-r--r--sysdeps/ia64/dl-fptr.c5
-rw-r--r--sysdeps/ia64/dl-machine.h8
-rw-r--r--sysdeps/unix/sysv/linux/dl-librecon.h2
-rw-r--r--sysdeps/unix/sysv/linux/dl-origin.c9
-rw-r--r--sysdeps/unix/sysv/linux/dl-osinfo.h4
-rw-r--r--sysdeps/unix/sysv/linux/getclktck.c8
-rw-r--r--sysdeps/unix/sysv/linux/getpagesize.c10
-rw-r--r--sysdeps/unix/sysv/linux/i386/dl-librecon.h12
-rw-r--r--sysdeps/unix/sysv/linux/ia64/dl-static.c4
-rw-r--r--sysdeps/unix/sysv/linux/ia64/getpagesize.c7
15 files changed, 174 insertions, 133 deletions
diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c
index 6ed26a3b7b..7ba00e46f7 100644
--- a/sysdeps/generic/dl-cache.c
+++ b/sysdeps/generic/dl-cache.c
@@ -1,5 +1,5 @@
 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
-   Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1996,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
@@ -26,8 +26,6 @@
 
 #include <stdio-common/_itoa.h>
 
-extern const char *_dl_platform;
-
 #ifndef _DL_PLATFORMS_COUNT
 # define _DL_PLATFORMS_COUNT 0
 #endif
@@ -154,7 +152,7 @@ _dl_load_cache_lookup (const char *name)
   const char *best;
 
   /* Print a message if the loading of libs is traced.  */
-  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
+  if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0))
     _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE);
 
   if (cache == NULL)
@@ -213,7 +211,9 @@ _dl_load_cache_lookup (const char *name)
       /* This file ends in static libraries where we don't have a hwcap.  */
       unsigned long int *hwcap;
       uint64_t platform;
+#ifndef SHARED
       weak_extern (_dl_hwcap);
+#endif
 
       /* This is where the strings start.  */
       cache_data = (const char *) cache_new;
@@ -221,14 +221,15 @@ _dl_load_cache_lookup (const char *name)
       /* Now we can compute how large the string table is.  */
       cache_data_size = (const char *) cache + cachesize - cache_data;
 
-      hwcap = &_dl_hwcap;
-      platform = _dl_string_platform (_dl_platform);
+      hwcap = &GL(dl_hwcap);
+      platform = _dl_string_platform (GL(dl_platform));
       if (platform != -1)
 	platform = 1ULL << platform;
 
       /* Only accept hwcap if it's for the right platform.  */
 #define HWCAP_CHECK \
-      if (_dl_osversion	&& cache_new->libs[middle].osversion > _dl_osversion) \
+      if (GL(dl_osversion)						      \
+	  && cache_new->libs[middle].osversion > GL(dl_osversion))	      \
 	continue;							      \
       if (_DL_PLATFORMS_COUNT && platform != -1				      \
 	  && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0			      \
@@ -253,7 +254,7 @@ _dl_load_cache_lookup (const char *name)
     }
 
   /* Print our result if wanted.  */
-  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0) && best != NULL)
+  if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0) && best != NULL)
     _dl_debug_printf ("  trying file=%s\n", best);
 
   return best;
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 8d182be9e9..2954b3309f 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,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 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
@@ -38,14 +38,7 @@
 #include <dl-osinfo.h>
 #include <hp-timing.h>
 
-extern int _dl_argc;
-extern char **_dl_argv;
 extern char **_environ;
-extern size_t _dl_pagesize;
-extern int _dl_clktck;
-extern const char *_dl_platform;
-extern unsigned long int _dl_hwcap;
-extern size_t _dl_platformlen;
 extern fpu_control_t _dl_fpu_control;
 extern void _end;
 
@@ -61,7 +54,7 @@ int __libc_multiple_libcs = 0;	/* Defining this here avoids the inclusion
 /* This variable contains the lowest stack address ever used.  */
 void *__libc_stack_end;
 static ElfW(auxv_t) *_dl_auxv;
-unsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
+//Xunsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
 #if HP_TIMING_AVAIL
 hp_timing_t _dl_cpuclock_offset;
 #endif
@@ -109,7 +102,7 @@ _dl_sysdep_start (void **start_argptr,
 			  _dl_auxv);
 
   user_entry = (ElfW(Addr)) ENTRY_POINT;
-  _dl_platform = NULL; /* Default to nothing known about the platform.  */
+  GL(dl_platform) = NULL; /* Default to nothing known about the platform.  */
 
   for (av = _dl_auxv; av->a_type != AT_NULL; set_seen (av++))
     switch (av->a_type)
@@ -121,7 +114,7 @@ _dl_sysdep_start (void **start_argptr,
 	phnum = av->a_un.a_val;
 	break;
       case AT_PAGESZ:
-	_dl_pagesize = av->a_un.a_val;
+	GL(dl_pagesize) = av->a_un.a_val;
 	break;
       case AT_ENTRY:
 	user_entry = av->a_un.a_val;
@@ -144,13 +137,13 @@ _dl_sysdep_start (void **start_argptr,
 	egid = av->a_un.a_val;
 	break;
       case AT_PLATFORM:
-	_dl_platform = av->a_un.a_ptr;
+	GL(dl_platform) = av->a_un.a_ptr;
 	break;
       case AT_HWCAP:
-	_dl_hwcap = av->a_un.a_val;
+	GL(dl_hwcap) = av->a_un.a_val;
 	break;
       case AT_CLKTCK:
-	_dl_clktck = av->a_un.a_val;
+	GL(dl_clktck) = av->a_un.a_val;
 	break;
       case AT_FPUCW:
 	_dl_fpu_control = av->a_un.a_val;
@@ -188,8 +181,8 @@ _dl_sysdep_start (void **start_argptr,
 #endif
 
   /* Determine the length of the platform name.  */
-  if (_dl_platform != NULL)
-    _dl_platformlen = strlen (_dl_platform);
+  if (GL(dl_platform) != NULL)
+    GL(dl_platformlen) = strlen (GL(dl_platform));
 
   if (__sbrk (0) == &_end)
     /* The dynamic linker was run as a program, and so the initial break
@@ -197,7 +190,7 @@ _dl_sysdep_start (void **start_argptr,
        will consume the rest of this page, so tell the kernel to move the
        break up that far.  When the user program examines its break, it
        will see this new value and not clobber our data.  */
-    __sbrk (_dl_pagesize - ((&_end - (void *) 0) & (_dl_pagesize - 1)));
+    __sbrk (GL(dl_pagesize) - ((&_end - (void *) 0) & (GL(dl_pagesize) - 1)));
 
   /* If this is a SUID program we make sure that FDs 0, 1, and 2 are
      allocated.  If necessary we are doing it ourself.  If it is not
@@ -288,7 +281,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
 		      size_t *max_capstrlen)
 {
   /* Determine how many important bits are set.  */
-  unsigned long int masked = _dl_hwcap & _dl_hwcap_mask;
+  unsigned long int masked = GL(dl_hwcap) & GL(dl_hwcap_mask);
   size_t cnt = platform != NULL;
   size_t n, m;
   size_t total;
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 837d32d0ca..52303327c0 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1,5 +1,5 @@
 /* Run-time dynamic linker data structures for loaded ELF shared objects.
-   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1995-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
@@ -29,6 +29,7 @@
 
 #include <elf.h>
 #include <dlfcn.h>
+#include <sys/mman.h>
 #include <link.h>
 #include <dl-lookupcfg.h>
 #include <bits/libc-lock.h>
@@ -189,29 +190,35 @@ typedef void (*receiver_fct) (int, const char *, const char *);
    user interface to run-time dynamic linking.  */
 
 
-/* Parameters passed to the dynamic linker.  */
-extern char **_dl_argv;
-
-/* Cached value of `getpagesize ()'.  */
-extern size_t _dl_pagesize;
-
-/* OS version.  */
-extern unsigned int _dl_osversion;
-
-/* File descriptor referring to the zero-fill device.  */
-extern int _dl_zerofd;
-
-/* Name of the shared object to be profiled (if any).  */
-extern const char *_dl_profile;
-/* Map of shared object to be profiled.  */
-extern struct link_map *_dl_profile_map;
-/* Filename of the output file.  */
-extern const char *_dl_profile_output;
-/* Map of shared object to be prelink traced.  */
-extern struct link_map *_dl_trace_prelink_map;
-
-/* If nonzero the appropriate debug information is printed.  */
-extern int _dl_debug_mask;
+#ifndef SHARED
+# define EXTERN extern
+# define GL(name) _##name
+#else
+# define EXTERN
+# define GL(name) _rtld_global._##name
+struct rtld_global
+{
+#endif
+  /* Don't change the order of the following elements.  'dl_loaded'
+     must remain the first element.  Forever.  */
+
+  /* And a pointer to the map for the main map.  */
+  EXTERN struct link_map *_dl_loaded;
+  /* Number of object in the _dl_loaded list.  */
+  EXTERN unsigned int _dl_nloaded;
+  /* Array representing global scope.  */
+  EXTERN struct r_scope_elem *_dl_global_scope[2];
+  /* Direct pointer to the searchlist of the main object.  */
+  EXTERN struct r_scope_elem *_dl_main_searchlist;
+  /* Copy of the content of `_dl_main_searchlist'.  */
+  EXTERN struct r_scope_elem _dl_initial_searchlist;
+  /* This is zero at program start to signal that the global scope map is
+     allocated by rtld.  Later it keeps the size of the map.  It might be
+     reset if in _dl_close if the last global object is removed.  */
+  EXTERN size_t _dl_global_scope_alloc;
+
+  /* If nonzero the appropriate debug information is printed.  */
+  EXTERN int _dl_debug_mask;
 #define DL_DEBUG_LIBS	    (1 << 0)
 #define DL_DEBUG_IMPCALLS   (1 << 1)
 #define DL_DEBUG_BINDINGS   (1 << 2)
@@ -224,33 +231,94 @@ extern int _dl_debug_mask;
 #define DL_DEBUG_HELP       (1 << 8)
 #define DL_DEBUG_PRELINK    (1 << 9)
 
-/* Expect cache ID.  */
-extern int _dl_correct_cache_id;
+  /* Cached value of `getpagesize ()'.  */
+  EXTERN size_t _dl_pagesize;
 
-/* Mask for hardware capabilities that are available.  */
-extern unsigned long int _dl_hwcap;
+  /* OS version.  */
+  EXTERN unsigned int _dl_osversion;
+  /* Platform name.  */
+  EXTERN const char *_dl_platform;
+  EXTERN size_t _dl_platformlen;
 
-/* Mask for important hardware capabilities we honour. */
-extern unsigned long int _dl_hwcap_mask;
+#ifndef MAP_ANON
+  /* File descriptor referring to the zero-fill device.  */
+  EXTERN int _dl_zerofd;
+#endif
 
-/* File descriptor to write debug messages to.  */
-extern int _dl_debug_fd;
+  /* CLK_TCK as reported by the kernel.  */
+  EXTERN int _dl_clktck;
 
-/* Names of shared object for which the RPATH should be ignored.  */
-extern const char *_dl_inhibit_rpath;
+  /* If nonzero print warnings messages.  */
+  EXTERN int _dl_verbose;
 
-/* Nonzero if references should be treated as weak during runtime linking.  */
-extern int _dl_dynamic_weak;
+  /* Nonzero if runtime lookups should not update the .got/.plt.  */
+  EXTERN int _dl_bind_not;
+
+  /* The object to be initialized first.  */
+  EXTERN struct link_map *_dl_initfirst;
+
+  /* Name of the shared object to be profiled (if any).  */
+  EXTERN const char *_dl_profile;
+  /* Map of shared object to be profiled.  */
+  EXTERN struct link_map *_dl_profile_map;
+  /* Filename of the output file.  */
+  EXTERN const char *_dl_profile_output;
+  /* Map of shared object to be prelink traced.  */
+  EXTERN struct link_map *_dl_trace_prelink_map;
+  /* Name of the object we want to trace the prelinking.  */
+  EXTERN const char *_dl_trace_prelink;
+
+  /* Expect cache ID.  */
+  EXTERN int _dl_correct_cache_id;
+
+  /* Counters for the number of relocations performed.  */
+  EXTERN unsigned long int _dl_num_relocations;
+  EXTERN unsigned long int _dl_num_cache_relocations;
+
+  /* Mask for hardware capabilities that are available.  */
+  EXTERN unsigned long int _dl_hwcap;
+
+  /* Mask for important hardware capabilities we honour. */
+  EXTERN unsigned long int _dl_hwcap_mask;
+
+  /* Names of shared object for which the RPATH should be ignored.  */
+  EXTERN const char *_dl_inhibit_rpath;
+
+  /* Location of the binary.  */
+  EXTERN const char *_dl_origin_path;
+
+  /* List of search directories.  */
+  EXTERN struct r_search_path_elem *_dl_all_dirs;
+  EXTERN struct r_search_path_elem *_dl_init_all_dirs;
+
+  /* Structure describing the dynamic linker itself.  */
+  EXTERN struct link_map _dl_rtld_map;
+#ifdef SHARED
+};
+extern struct rtld_global _rtld_global;
+#endif
+#undef EXTERN
+
+/* Parameters passed to the dynamic linker.  */
+extern int _dl_argc;
+extern char **_dl_argv;
+
+/* Do we do lazy relocations?  */
+extern int _dl_lazy;
 
 /* The array with message we print as a last resort.  */
 extern const char _dl_out_of_memory[];
 
-/* Nonzero if runtime lookups should not update the .got/.plt.  */
-extern int _dl_bind_not;
+/* File descriptor to write debug messages to.  */
+extern int _dl_debug_fd;
+
+/* Nonzero if references should be treated as weak during runtime
+   linking.
+
+   XXX Once we can set the default for this variable to zero move it
+   into _rtld_global.  */
+extern int _dl_dynamic_weak;
 
-/* List of search directories.  */
-extern struct r_search_path_elem *_dl_all_dirs;
-extern struct r_search_path_elem *_dl_init_all_dirs;
 
 /* OS-dependent function to open the zero-fill device.  */
 extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
@@ -400,24 +468,6 @@ extern lookup_t _dl_lookup_versioned_symbol_skip (const char *undef,
 extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
      internal_function;
 
-
-/* Structure describing the dynamic linker itself.  */
-extern struct link_map _dl_rtld_map;
-/* And a pointer to the map for the main map.  */
-extern struct link_map *_dl_loaded;
-/* Number of object in the _dl_loaded list.  */
-extern unsigned int _dl_nloaded;
-/* Array representing global scope.  */
-extern struct r_scope_elem *_dl_global_scope[2];
-/* Direct pointer to the searchlist of the main object.  */
-extern struct r_scope_elem *_dl_main_searchlist;
-/* Copy of the content of `_dl_main_searchlist'.  */
-extern struct r_scope_elem _dl_initial_searchlist;
-/* This is zero at program start to signal that the global scope map is
-   allocated by rtld.  Later it keeps the size of the map.  It might be
-   reset if in _dl_close if the last global object is removed.  */
-extern size_t _dl_global_scope_alloc;
-
 /* Allocate a `struct link_map' for a new object being loaded,
    and enter it into the _dl_main_map list.  */
 extern struct link_map *_dl_new_object (char *realname, const char *libname,
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index 71aef46731..4d1748614e 100644
--- a/sysdeps/generic/libc-start.c
+++ b/sysdeps/generic/libc-start.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -115,14 +115,14 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
 
   /* Call the initializer of the program, if any.  */
 #ifdef SHARED
-  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
+  if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
     _dl_debug_printf ("\ninitialize program: %s\n\n", argv[0]);
 #endif
   if (init)
     (*init) ();
 
 #ifdef SHARED
-  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
+  if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
     _dl_debug_printf ("\ntransferring control: %s\n\n", argv[0]);
 #endif
 
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index b86f11724b..338dbfbdbe 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  i386 version.
-   Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,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
@@ -94,7 +94,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 	{
 	  l->l_mach.plt = got[1] + l->l_addr;
 	  l->l_mach.gotplt = (Elf32_Addr) &got[3];
-	}	  
+	}
       got[1] = (Elf32_Addr) l;	/* Identify this shared object.  */
 
       /* The got[2] entry contains the address of a function which gets
@@ -107,10 +107,10 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 	{
 	  got[2] = (Elf32_Addr) &_dl_runtime_profile;
 
-	  if (_dl_name_match_p (_dl_profile, l))
+	  if (_dl_name_match_p (GL(dl_profile), l))
 	    /* This is the object we are looking for.  Say that we really
 	       want profiling and the timers are started.  */
-	    _dl_profile_map = l;
+	    GL(dl_profile_map) = l;
 	}
       else
 	/* This function will get called to fix up the GOT entry indicated by
@@ -237,7 +237,7 @@ _dl_start_user:\n\
 " RTLD_START_SPECIAL_INIT "\n\
 	# Load the parameters again.\n\
 	# (eax, edx, ecx, *--esp) = (_dl_loaded, argc, argv, envp)\n\
-	movl _dl_loaded@GOT(%ebx), %esi\n\
+	movl _rtld_global@GOT(%ebx), %esi\n\
 	leal 8(%esp,%edx,4), %eax\n\
 	leal 4(%esp), %ecx\n\
 	pushl %eax\n\
@@ -274,14 +274,12 @@ _dl_start_user:\n\
    _dl_sysdep_start.  */
 #define DL_PLATFORM_INIT dl_platform_init ()
 
-extern const char *_dl_platform;
-
 static inline void __attribute__ ((unused))
 dl_platform_init (void)
 {
-  if (_dl_platform != NULL && *_dl_platform == '\0')
+  if (GL(dl_platform) != NULL && *GL(dl_platform) == '\0')
     /* Avoid an empty string which would disturb us.  */
-    _dl_platform = NULL;
+    GL(dl_platform) = NULL;
 }
 
 static inline Elf32_Addr
@@ -372,7 +370,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	    break;
 	  if (__builtin_expect (sym->st_size > refsym->st_size, 0)
 	      || (__builtin_expect (sym->st_size < refsym->st_size, 0)
-		  && _dl_verbose))
+		  && GL(dl_verbose)))
 	    {
 	      const char *strtab;
 
diff --git a/sysdeps/ia64/dl-fptr.c b/sysdeps/ia64/dl-fptr.c
index 6916635281..dd8eb9d391 100644
--- a/sysdeps/ia64/dl-fptr.c
+++ b/sysdeps/ia64/dl-fptr.c
@@ -101,7 +101,7 @@ local =
 static struct ia64_fdesc *
 new_fdesc_table (struct local *l)
 {
-  size_t size = l->npages * _dl_pagesize;
+  size_t size = l->npages * GL(dl_pagesize);
   struct ia64_fdesc_table *new_table;
   struct ia64_fdesc *fdesc;
 
@@ -174,7 +174,8 @@ make_fptr_table (struct link_map *map)
      symbol section is to assume that the string table follows right
      afterwards...  */
   len = ((strtab - (char *) symtab) / map->l_info[DT_SYMENT]->d_un.d_val);
-  size = ((len * sizeof (fptr_table[0]) + _dl_pagesize - 1) & -_dl_pagesize);
+  size = ((len * sizeof (fptr_table[0]) + GL(dl_pagesize) - 1)
+	  & -GL(dl_pagesize));
   /* XXX We don't support here in the moment systems without MAP_ANON.
      There probably are none for IA-64.  In case this is proven wrong
      we will have to open /dev/null here and use the file descriptor
diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
index 2af418c122..b81cf29ebd 100644
--- a/sysdeps/ia64/dl-machine.h
+++ b/sysdeps/ia64/dl-machine.h
@@ -145,11 +145,11 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 	doit = (Elf64_Addr) ((struct ia64_fdesc *) &_dl_runtime_resolve)->ip;
       else
 	{
-	  if (_dl_name_match_p (_dl_profile, l))
+	  if (_dl_name_match_p (GL(dl_profile), l))
 	    {
 	      /* This is the object we are looking for.  Say that we really
 		 want profiling and the timers are started.  */
-	      _dl_profile_map = l;
+	      GL(dl_profile_map) = l;
 	    }
 	  doit = (Elf64_Addr) ((struct ia64_fdesc *) &_dl_runtime_profile)->ip;
 	}
@@ -381,7 +381,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 "	{ .mmi\n"							      \
 "	  mov out3 = r11\n"						      \
 "	  sub r17 = r17, r3	/* Substract _dl_skip_args. */\n"	      \
-"	  addl out0 = @ltoff(_dl_loaded), gp\n"				      \
+"	  addl out0 = @ltoff(_rtld_global), gp\n"			      \
 "	}\n"								      \
 "1:	/* Copy env. */\n"						      \
 "	{ .mfi\n"							      \
@@ -528,7 +528,7 @@ elf_machine_rela (struct link_map *map,
       value = *reloc_addr;
 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
       /* Already done in dynamic linker.  */
-      if (map != &_dl_rtld_map)
+      if (map != &GL(dl_rtld_map))
 # endif
         value += map->l_addr;
     }
diff --git a/sysdeps/unix/sysv/linux/dl-librecon.h b/sysdeps/unix/sysv/linux/dl-librecon.h
index 5c34d00edb..d98afcb8a8 100644
--- a/sysdeps/unix/sysv/linux/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/dl-librecon.h
@@ -42,7 +42,7 @@
 	      break;							      \
 	  }								      \
 	if (osversion)							      \
-	  _dl_osversion = osversion;					      \
+	  GL(dl_osversion) = osversion;					      \
 	break;								      \
       }
 
diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c
index 9149a0a4de..90add58ef5 100644
--- a/sysdeps/unix/sysv/linux/dl-origin.c
+++ b/sysdeps/unix/sysv/linux/dl-origin.c
@@ -1,5 +1,5 @@
 /* Find path of executable.
-   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -29,7 +29,6 @@
 /* On Linux >= 2.1 systems which have the dcache implementation we can get
    the path of the application from the /proc/self/exe symlink.  Try this
    first and fall back on the generic method if necessary.  */
-extern const char *_dl_origin_path;
 
 const char *
 _dl_get_origin (void)
@@ -55,15 +54,15 @@ _dl_get_origin (void)
       result = (char *) -1;
       /* We use the environment variable LD_ORIGIN_PATH.  If it is set make
 	 a copy and strip out trailing slashes.  */
-      if (_dl_origin_path != NULL)
+      if (GL(dl_origin_path) != NULL)
 	{
-	  size_t len = strlen (_dl_origin_path);
+	  size_t len = strlen (GL(dl_origin_path));
 	  result = malloc (len + 1);
 	  if (result == NULL)
 	    result = (char *) -1;
 	  else
 	    {
-	      char *cp = __mempcpy (result, _dl_origin_path, len);
+	      char *cp = __mempcpy (result, GL(dl_origin_path), len);
 	      while (cp > result + 1 && cp[-1] == '/')
 		--cp;
 	      *cp = '\0';
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 4976b3126d..1510b5b8c7 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -1,5 +1,5 @@
 /* Operating system specific code  for generic dynamic loader functions.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -103,6 +103,6 @@ dl_fatal (const char *str)
 	  /* Not sufficent.  */						      \
 	  FATAL ("FATAL: kernel too old\n");				      \
 									      \
-	_dl_osversion = version;					      \
+	GL(dl_osversion) = version;					      \
       }									      \
   } while (0)
diff --git a/sysdeps/unix/sysv/linux/getclktck.c b/sysdeps/unix/sysv/linux/getclktck.c
index 57deaa3727..dc8ec9b50b 100644
--- a/sysdeps/unix/sysv/linux/getclktck.c
+++ b/sysdeps/unix/sysv/linux/getclktck.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 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
@@ -18,6 +18,8 @@
 
 #include <time.h>
 
+#include <ldsodefs.h>
+
 #ifndef SYSTEM_CLK_TCK
 # define SYSTEM_CLK_TCK	100
 #endif
@@ -26,7 +28,5 @@
 int
 __getclktck ()
 {
-  extern int _dl_clktck;	/* Defined in dl-load.c.  */
-
-  return _dl_clktck ?: SYSTEM_CLK_TCK;
+  return GL(dl_clktck) ?: SYSTEM_CLK_TCK;
 }
diff --git a/sysdeps/unix/sysv/linux/getpagesize.c b/sysdeps/unix/sysv/linux/getpagesize.c
index a1796e8714..f030abc61b 100644
--- a/sysdeps/unix/sysv/linux/getpagesize.c
+++ b/sysdeps/unix/sysv/linux/getpagesize.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1995,1996,1997,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995-1997,2000,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
@@ -19,14 +19,14 @@
 #include <unistd.h>
 #include <sys/param.h>
 
+#include <ldsodefs.h>
+
 /* Return the system page size.  */
 int
 __getpagesize ()
 {
-  extern size_t _dl_pagesize;
-
-  if (_dl_pagesize != 0)
-    return _dl_pagesize;
+  if (GL(dl_pagesize) != 0)
+    return GL(dl_pagesize);
 
 #ifdef	EXEC_PAGESIZE
   return EXEC_PAGESIZE;
diff --git a/sysdeps/unix/sysv/linux/i386/dl-librecon.h b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
index 3e39a32e69..e01631146a 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
@@ -1,5 +1,5 @@
 /* Optional code to distinguish library flavours.
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -27,15 +27,15 @@
       /* We have to find out whether the binary is linked against	      \
 	 libc 5 or glibc.  We do this by looking at all the DT_NEEDED	      \
 	 entries.  If one is libc.so.5 this is a libc 5 linked binary.  */    \
-      if (_dl_loaded->l_info[DT_NEEDED])				      \
+      if (GL(dl_loaded)->l_info[DT_NEEDED])				      \
 	{								      \
 	  /* We have dependencies.  */					      \
 	  const ElfW(Dyn) *d;						      \
 	  const char *strtab;						      \
 									      \
-	  strtab = (const char *) D_PTR (_dl_loaded, l_info[DT_STRTAB]);      \
+	  strtab = (const char *) D_PTR (GL(dl_loaded), l_info[DT_STRTAB]);   \
 									      \
-	  for (d = _dl_loaded->l_ld; d->d_tag != DT_NULL; ++d)		      \
+	  for (d = GL(dl_loaded)->l_ld; d->d_tag != DT_NULL; ++d)	      \
 	    if (d->d_tag == DT_NEEDED					      \
 		&& strcmp (strtab + d->d_un.d_val, "libc.so.5") == 0)	      \
 	      break;							      \
@@ -67,14 +67,14 @@
 	      break;							      \
 	  }								      \
 	if (osversion)							      \
-	  _dl_osversion = osversion;					      \
+	  GL(dl_osversion) = osversion;					      \
 	break;								      \
       }									      \
 									      \
   case 15:								      \
     if (memcmp (envline, "LIBRARY_VERSION", 15) == 0)			      \
       {									      \
-	_dl_correct_cache_id = envline[16] == '5' ? 2 : 3;		      \
+	GL(dl_correct_cache_id) = envline[16] == '5' ? 2 : 3;		      \
 	break;								      \
       }
 
diff --git a/sysdeps/unix/sysv/linux/ia64/dl-static.c b/sysdeps/unix/sysv/linux/ia64/dl-static.c
index 8be9d58b01..f74353e725 100644
--- a/sysdeps/unix/sysv/linux/ia64/dl-static.c
+++ b/sysdeps/unix/sysv/linux/ia64/dl-static.c
@@ -33,8 +33,8 @@ _dl_var_init (void *array[])
       DL_CLKTCK
     };
 
-  _dl_pagesize = *((size_t *) array[DL_PAGESIZE]);
-  _dl_clktck = *((int *) array[DL_CLKTCK]);
+  GL(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+  GL(dl_clktck) = *((int *) array[DL_CLKTCK]);
 }
 
 #else
diff --git a/sysdeps/unix/sysv/linux/ia64/getpagesize.c b/sysdeps/unix/sysv/linux/ia64/getpagesize.c
index 67d0a3a5c2..0f1f8e13ed 100644
--- a/sysdeps/unix/sysv/linux/ia64/getpagesize.c
+++ b/sysdeps/unix/sysv/linux/ia64/getpagesize.c
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <sys/param.h>
 
+#include <ldsodefs.h>
 #include <sysdep.h>
 #include <sys/syscall.h>
 
@@ -28,13 +29,11 @@
    determine the page size to ensure proper alignment for calls such
    as mmap and friends.  --davidm 99/11/30 */
 
-extern size_t _dl_pagesize;
-
 int
 __getpagesize ()
 {
-  assert (_dl_pagesize != 0);
-  return _dl_pagesize;
+  assert (GL(dl_pagesize) != 0);
+  return GL(dl_pagesize);
 }
 
 weak_alias (__getpagesize, getpagesize)