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] Re: ld.so changes


On Wed, Jan 30, 2002 at 07:47:03PM -0800, Ulrich Drepper wrote:
> I've jsut checked in a larger patch to improve ld.so performance.  Not
> much, only about 2-5% but it's something.  The binary should be
> smaller as well.  The idea is to move all global variables in one
> struct.  Only for the SHARED code.  This way there are not dozens of
> GOT entries for those variables (only one) and accessing more than one
> of the ex-global variabes in one function should ideally be faster
> since the address of the struct canbe saved.  Could save one
> indirection.  I fear gcc does not the best job in the mement, at least
> the 2.96 I use.  But still it's better.
> 
> A side effect is also that the global variable handling in more
> organized.  Definitions and prototypes are not spread across lots
> source files.  This way I've found one completely unused variable.
> 
> What is important to know for everybody else is that I broke all
> architectures.  All of them (except x86 and IA64) need fixing.  Simply
> replace uses of, say, _dl_loaded with GL(dl_loaded).  GL for global.
> Remove the initial underscore.  That's it.  Only other tricky thing is
> that the startup code _dl_start_user normally accesses a variable
> _dl_loaded.  Replace this with _rtld_global and you're set.
> 
> 
> Which reminds me.  The IA64 startup code pokes into _dl_argv.  It
> should have to do this.  The parameters are all on the stack and the
> assembler code should be able to find it.  Please, somebody change
> that if possible.  It prevents the _dl_argv variable from going into
> this struct.
> 
> 
> I'll probably fix Alpha myself tomorrow or when I have time but
> everything else must be handled by the appropriate maintainer.

I did all I found.
Few problems:
a) _dl_correct_cache_id and _dl_hwcap_mask need to be initialized.
   Do you prefer to initialize them in rtld.c using
   _rtld_global = { ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
		    .dl_hwcap_mask = HWCAP_IMPORTANT };
   ?
   One problem is that both these definitions are in headers
   which include lots of cruft rtld.c probably shouldn't get in.
   Such initialization is commented out with //X (like you did already
   once).
b) Many ports did weak_extern(_dl_rtld_map); if (map == &_dl_rtld_map)
   etc. (or similarly with _dl_hwcap). I've replaced these
   with #ifndef SHARED weak_extern(_dl_rtld_map) #endif if (map == &GL(dl_rtld_map))
   Is that correct or does dynamic libc need those references weak as well
   (I think ld.so is dynamically linked in when static executable does
   nss lookups)
c) Are all the variables from _rtld_global defined somewhere #ifndef SHARED?

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.

--- libc/sysdeps/alpha/dl-machine.h.jj	Wed Jan 30 18:02:55 2002
+++ libc/sysdeps/alpha/dl-machine.h	Thu Jan 31 20:26:24 2002
@@ -110,11 +110,11 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  *(Elf64_Addr *)(plt + 16) = (Elf64_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;
 	    }
 	}
 
@@ -328,7 +328,7 @@ $fixup_stack_ret:						\n\
 " RTLD_START_SPECIAL_INIT "					\n\
 	/* Call _dl_init(_dl_loaded, argc, argv, envp) to run	\n\
 	   initializers.  */					\n\
-	ldq	$16, _dl_loaded					\n\
+	ldq	$16, _rtld_global				\n\
 	ldq	$17, 0($sp)					\n\
 	lda	$18, 8($sp)					\n\
 	s8addq	$17, 8, $19					\n\
@@ -498,7 +498,7 @@ elf_machine_rela (struct link_map *map,
 {
   unsigned long int const r_type = ELF64_R_TYPE (reloc->r_info);
 
-#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
+#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
   /* This is defined in rtld.c, but nowhere in the static libc.a; make the
      reference weak so static programs can still link.  This declaration
      cannot be done when compiling rtld.c (i.e.  #ifdef RTLD_BOOTSTRAP)
@@ -506,6 +506,7 @@ elf_machine_rela (struct link_map *map,
      incompatible with a weak decl in the same file.  */
   weak_extern (_dl_rtld_map);
 #endif
+#endif
 
   /* We cannot use a switch here because we cannot locate the switch
      jump table until we've self-relocated.  */
@@ -515,7 +516,7 @@ elf_machine_rela (struct link_map *map,
     {
 # 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
 	{
 	  /* XXX Make some timings.  Maybe it's preverable to test for
--- libc/sysdeps/arm/dl-machine.h.jj	Thu Dec 27 21:02:24 2001
+++ libc/sysdeps/arm/dl-machine.h	Thu Jan 31 20:27:18 2002
@@ -109,10 +109,10 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  got[2] = (Elf32_Addr) &_dl_runtime_profile;
 
-	  if (_dl_name_match_p (_dl_profile, l))
+	  if (_dl_name_match_p (GL(dl_profile), l))
 	    /* 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
@@ -324,7 +324,7 @@ _dl_start_user:
 .L_STACK_END:
 	.word	__libc_stack_end(GOT)
 .L_LOADED:
-	.word	_dl_loaded(GOT)
+	.word	_rtld_global(GOT)
 .previous\n\
 ");
 
@@ -347,14 +347,12 @@ _dl_start_user:
    _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
@@ -452,7 +450,7 @@ elf_machine_rel (struct link_map *map, c
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (_dl_verbose && sym->st_size < refsym->st_size))
+	      || (GL(dl_verbose) && sym->st_size < refsym->st_size))
 	    {
 	      const char *strtab;
 
@@ -484,7 +482,9 @@ elf_machine_rel (struct link_map *map, c
 	      compiling rtld.c (i.e.  #ifdef RTLD_BOOTSTRAP) because
 	      rtld.c contains the common defn for _dl_rtld_map, which
 	      is incompatible with a weak decl in the same file.  */
+#ifndef SHARED
 	    weak_extern (_dl_rtld_map);
+#endif
 	    if (map == &_dl_rtld_map)
 	      /* Undo the relocation done here during bootstrapping.
 		 Now we will relocate it anew, possibly using a
--- libc/sysdeps/generic/dl-origin.c.jj	Thu Aug 23 18:49:27 2001
+++ libc/sysdeps/generic/dl-origin.c	Thu Jan 31 20:16:53 2002
@@ -25,25 +25,21 @@
 
 #include <dl-dst.h>
 
-/* Generally it is not possible to implement this.  We have to fall
-   back on a solution where the user provides the information.  */
-extern const char *_dl_origin_path;
-
 const char *
 _dl_get_origin (void)
 {
   char *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';
--- libc/sysdeps/generic/dl-sysdep.c.jj	Thu Jan 31 11:40:32 2002
+++ libc/sysdeps/generic/dl-sysdep.c	Thu Jan 31 20:17:47 2002
@@ -168,8 +168,8 @@ _dl_sysdep_start (void **start_argptr,
   __libc_enable_secure = uid != euid || gid != egid;
 
 #ifndef HAVE_AUX_PAGESIZE
-  if (_dl_pagesize == 0)
-    _dl_pagesize = __getpagesize ();
+  if (GL(dl_pagesize) == 0)
+    GL(dl_pagesize) = __getpagesize ();
 #endif
 
 #ifdef DL_SYSDEP_INIT
--- libc/sysdeps/generic/dl-cache.c.jj	Thu Jan 31 11:40:32 2002
+++ libc/sysdeps/generic/dl-cache.c	Thu Jan 31 21:08:20 2002
@@ -40,7 +40,7 @@ static size_t cachesize;
 
 /* This is the cache ID we expect.  Normally it is 3 for glibc linked
    binaries.  */
-int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
+//Xint _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
 
 #define SEARCH_CACHE(cache) \
 /* We use binary search since the table is sorted in the cache file.	      \
@@ -111,12 +111,12 @@ do									      \
 		if (_dl_cache_check_flags (flags)			      \
 		    && _dl_cache_verify_ptr (lib->value))		      \
 		  {							      \
-		    if (best == NULL || flags == _dl_correct_cache_id)	      \
+		    if (best == NULL || flags == GL(dl_correct_cache_id))     \
 		      {							      \
 			HWCAP_CHECK;					      \
 			best = cache_data + lib->value;			      \
 									      \
-			if (flags == _dl_correct_cache_id)		      \
+			if (flags == GL(dl_correct_cache_id))		      \
 			  /* We've found an exact match for the shared	      \
 			     object and no general `ELF' release.  Stop	      \
 			     searching.  */				      \
--- libc/sysdeps/hppa/dl-fptr.c.jj	Wed Sep 12 09:56:56 2001
+++ libc/sysdeps/hppa/dl-fptr.c	Thu Jan 31 20:29:00 2002
@@ -46,8 +46,7 @@ static int __hppa_fptr_lock = 1;
 /* The fd is not examined when using MAP_ANON.  */
 #define ANONFD -1
 #else
-extern int _dl_zerofd;
-#define ANONFD _dl_zerofd
+#define ANONFD GL(dl_zerofd)
 #endif
 
 struct hppa_fptr __boot_ldso_fptr[HPPA_BOOT_FPTR_SIZE];
@@ -95,10 +94,10 @@ __hppa_make_fptr (const struct link_map 
 	{
 #ifndef MAP_ANON
 # define MAP_ANON 0
-	  if (_dl_zerofd == -1)
+	  if (GL(dl_zerofd) == -1)
 	    {
-	      _dl_zerofd = _dl_sysdep_open_zero_fill ();
-	      if (_dl_zerofd == -1)
+	      GL(dl_zerofd) = _dl_sysdep_open_zero_fill ();
+	      if (GL(dl_zerofd) == -1)
 		{
 		  __close (fd);
 		  _dl_signal_error (errno, NULL, NULL,
@@ -107,11 +106,11 @@ __hppa_make_fptr (const struct link_map 
 	    }
 #endif
 
-	  __fptr_next = __mmap (0, _dl_pagesize, PROT_READ | PROT_WRITE,
+	  __fptr_next = __mmap (0, GL(dl_pagesize), PROT_READ | PROT_WRITE,
 				MAP_ANON | MAP_PRIVATE, ANONFD, 0);
 	  if (__fptr_next == MAP_FAILED)
 	    _dl_signal_error(errno, NULL, NULL, "cannot map page for fptr");
-	  __fptr_count = _dl_pagesize / sizeof (struct hppa_fptr);
+	  __fptr_count = GL(dl_pagesize) / sizeof (struct hppa_fptr);
 	}
       f = __fptr_next++;
       __fptr_count--;
--- libc/sysdeps/hppa/dl-machine.h.jj	Mon Aug 27 12:04:30 2001
+++ libc/sysdeps/hppa/dl-machine.h	Thu Jan 31 20:33:56 2002
@@ -227,12 +227,12 @@ elf_machine_runtime_setup (struct link_m
 			    ((unsigned long) &_dl_runtime_resolve & ~3))->func;
 	  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;
 		}
 	      got[-2] =
 		(Elf32_Addr) ((struct hppa_fptr *)
@@ -362,8 +362,8 @@ asm (									\
 "	stw	%r24,-44(%sp)\n"					\
 									\
 ".Lnofix:\n"								\
-"	addil	LT'_dl_loaded,%r19\n"					\
-"	ldw	RT'_dl_loaded(%r1),%r26\n"				\
+"	addil	LT'_rtld_global,%r19\n"					\
+"	ldw	RT'_rtld_global(%r1),%r26\n"				\
 "	bl	set_dp, %r2\n"						\
 "	ldw	0(%r26),%r26\n"						\
 									\
@@ -488,7 +488,7 @@ elf_machine_rela (struct link_map *map, 
   struct link_map *sym_map;
   Elf32_Addr value;
 
-#ifndef RTLD_BOOTSTRAP
+#if !defined RTLD_BOOTSTRAP && !defined SHARED
   /* This is defined in rtld.c, but nowhere in the static libc.a; make the
      reference weak so static programs can still link.  This declaration
      cannot be done when compiling rtld.c (i.e.  #ifdef RTLD_BOOTSTRAP)
@@ -527,7 +527,7 @@ elf_machine_rela (struct link_map *map, 
          other ones will have their values reset.  In particular,
          __fptr_next will be reset, sometimes causing endless loops in
          __hppa_make_fptr().  So don't do that. */
-      if (map == &_dl_rtld_map)
+      if (map == &GL(dl_rtld_map))
 	return;
 #endif
       /* .eh_frame can have unaligned relocs.  */
@@ -604,7 +604,7 @@ elf_machine_rela (struct link_map *map, 
 	break;
       if (__builtin_expect (sym->st_size > refsym->st_size, 0)
 	  || (__builtin_expect (sym->st_size < refsym->st_size, 0)
-	      && __builtin_expect (_dl_verbose, 0)))
+	      && __builtin_expect (GL(dl_verbose), 0)))
 	{
 	  const char *strtab;
 
--- libc/sysdeps/cris/dl-machine.h.jj	Mon Aug 27 12:04:17 2001
+++ libc/sysdeps/cris/dl-machine.h	Thu Jan 31 20:35:28 2002
@@ -106,11 +106,11 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  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
@@ -212,7 +212,7 @@ _dl_start_user:
 	move.d	$sp,$r12
 	addq	4,$r12
 	;  main_map: at _dl_loaded.
-	move.d	[$r0+_dl_loaded:GOT16],$r9
+	move.d	[$r0+_rtld_global:GOT16],$r9
 	move.d	[$r9],$r10
 	move.d	_dl_init:PLTG,$r9
 	add.d	$r0,$r9
@@ -246,14 +246,12 @@ _dl_start_user:
    _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
@@ -314,7 +312,7 @@ elf_machine_rela (struct link_map *map, 
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (_dl_verbose && sym->st_size < refsym->st_size))
+	      || (GL(dl_verbose) && sym->st_size < refsym->st_size))
 	    {
 	      extern char **_dl_argv;
 	      const char *strtab;
--- libc/sysdeps/i386/dl-machine.h.jj	Thu Jan 31 11:40:32 2002
+++ libc/sysdeps/i386/dl-machine.h	Thu Jan 31 20:36:15 2002
@@ -328,8 +328,10 @@ elf_machine_rel (struct link_map *map, c
 	 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
 	 common defn for _dl_rtld_map, which is incompatible with a
 	 weak decl in the same file.  */
+#ifndef SHARED
       weak_extern (_dl_rtld_map);
-      if (map != &_dl_rtld_map) /* Already done in rtld itself.  */
+#endif
+      if (map != &GL(dl_rtld_map)) /* Already done in rtld itself.  */
 # endif
 	*reloc_addr += map->l_addr;
     }
--- libc/sysdeps/ia64/dl-machine.h.jj	Thu Jan 31 11:40:32 2002
+++ libc/sysdeps/ia64/dl-machine.h	Thu Jan 31 20:36:48 2002
@@ -508,7 +508,7 @@ elf_machine_rela (struct link_map *map,
   const unsigned long int r_type = ELF64_R_TYPE (reloc->r_info);
   Elf64_Addr value;
 
-#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
+#if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
   /* This is defined in rtld.c, but nowhere in the static libc.a; make the
      reference weak so static programs can still link.  This declaration
      cannot be done when compiling rtld.c (i.e.  #ifdef RTLD_BOOTSTRAP)
--- libc/sysdeps/m68k/dl-machine.h.jj	Mon Aug 27 12:04:30 2001
+++ libc/sysdeps/m68k/dl-machine.h	Thu Jan 31 20:37:49 2002
@@ -85,11 +85,11 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  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
@@ -176,7 +176,7 @@ _dl_start_user:
 	pea 8(%sp, %d1*4)
 	pea 8(%sp)
 	move.l %d1, -(%sp)
-	move.l ([_dl_loaded@GOT.w, %a5]), -(%sp)
+	move.l ([_rtld_global@GOT.w, %a5]), -(%sp)
 	jbsr _dl_init@PLTPC
 	addq.l #8, %sp
 	addq.l #8, %sp
@@ -251,7 +251,7 @@ elf_machine_rela (struct link_map *map, 
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (sym->st_size < refsym->st_size && _dl_verbose))
+	      || (sym->st_size < refsym->st_size && GL(dl_verbose)))
 	    {
 	      extern char **_dl_argv;
 	      const char *strtab;
--- libc/sysdeps/mach/hurd/dl-sysdep.c.jj	Wed Sep 12 09:57:00 2001
+++ libc/sysdeps/mach/hurd/dl-sysdep.c	Thu Jan 31 20:40:10 2002
@@ -52,7 +52,7 @@ int __libc_multiple_libcs = 0;	/* Defini
 				   of init-first.  */
 /* This variable containts the lowest stack address ever used.  */
 void *__libc_stack_end;
-unsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
+//Xunsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
 
 
 struct hurd_startup_data *_dl_hurd_data;
@@ -236,7 +236,7 @@ unfmh();			/* XXX */
   __mach_init ();
 
   /* Initialize frequently used global variable.  */
-  _dl_pagesize = __getpagesize ();
+  GL(dl_pagesize) = __getpagesize ();
 
 fmh();				/* XXX */
 
--- libc/sysdeps/mips/mips64/dl-machine.h.jj	Wed Sep 12 09:57:00 2001
+++ libc/sysdeps/mips/mips64/dl-machine.h	Thu Jan 31 20:43:51 2002
@@ -289,7 +289,7 @@ elf_machine_runtime_link_map (ElfW(Addr)
     }
 
     {
-      struct link_map *l = _dl_loaded;
+      struct link_map *l = GL(dl_loaded);
 
       while (l)
 	{
@@ -480,7 +480,7 @@ _dl_start_user:\n\
 	# Save back the modified argument count.\n\
 	sd $4, 0($29)\n\
 1:	# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
-	ld $4, _dl_loaded\n\
+	ld $4, _rtld_global\n\
 	ld $5, 0($29)\n\
 	dla $6, 4($29)\n\
 	dla $7, 8($29)\n\
@@ -492,7 +492,7 @@ _dl_start_user:\n\
 	dla $31, _dl_fini\n\
 	# Jump to the user entry point.\n\
 1:	# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
-	lw $4, _dl_loaded\n\
+	lw $4, _rtld_global\n\
 	lw $5, 0($29)\n\
 	la $6, 4($29)\n\
 	la $7, 8($29)\n\
@@ -553,8 +553,10 @@ elf_machine_rel (struct link_map *map, c
 	   RTLD_BOOTSTRAP) because rtld.c contains the common defn for
 	   _dl_rtld_map, which is incompatible with a weak decl in the same
 	   file.  */
+#ifndef SHARED
 	weak_extern (_dl_rtld_map);
-	if (map == &_dl_rtld_map)
+#endif
+	if (map == &GL(dl_rtld_map))
 	  /* Undo the relocation done here during bootstrapping.  Now we will
 	     relocate it anew, possibly using a binding found in the user
 	     program or a loaded library rather than the dynamic linker's
--- libc/sysdeps/mips/dl-machine.h.jj	Wed Jan 30 18:03:36 2002
+++ libc/sysdeps/mips/dl-machine.h	Thu Jan 31 20:42:39 2002
@@ -216,7 +216,7 @@ elf_machine_runtime_link_map (ElfW(Addr)
     }
 
     {
-      struct link_map *l = _dl_loaded;
+      struct link_map *l = GL(dl_loaded);
 
       while (l)
 	{
@@ -441,7 +441,7 @@ _dl_start_user:\n\
 	# Save back the modified argument count.\n\
 	sw $4, 0($29)\n\
 1:	# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
-	lw $4, _dl_loaded\n\
+	lw $4, _rtld_global\n\
 	lw $5, 0($29)\n\
 	la $6, 4($29)\n\
 	sll $7, $5, 2\n\
@@ -477,7 +477,7 @@ elf_machine_rel (struct link_map *map, c
 {
   const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
 
-#ifndef RTLD_BOOTSTRAP
+#if !defined RTLD_BOOTSTRAP && !defined SHARED
   /* This is defined in rtld.c, but nowhere in the static libc.a;
      make the reference weak so static programs can still link.  This
      declaration cannot be done when compiling rtld.c (i.e.  #ifdef
@@ -501,7 +501,7 @@ elf_machine_rel (struct link_map *map, c
 	    if (symidx < gotsym)
 	      {
 #ifndef RTLD_BOOTSTRAP
-		if (map != &_dl_rtld_map)
+		if (map != &GL(dl_rtld_map))
 #endif
 		  *reloc_addr += sym->st_value + map->l_addr;
 	      }
@@ -520,7 +520,7 @@ elf_machine_rel (struct link_map *map, c
 	  }
 	else
 #ifndef RTLD_BOOTSTRAP
-	  if (map != &_dl_rtld_map)
+	  if (map != &GL(dl_rtld_map))
 #endif
 	    *reloc_addr += map->l_addr;
       }
@@ -576,7 +576,7 @@ elf_machine_got_rel (struct link_map *ma
 
   n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
   /* The dynamic linker's local got entries have already been relocated.  */
-  if (map != &_dl_rtld_map)
+  if (map != &GL(dl_rtld_map))
     {
       /* got[0] is reserved. got[1] is also reserved for the dynamic object
 	 generated by gnu ld. Skip these reserved entries from relocation.  */
--- libc/sysdeps/powerpc/elf/libc-start.c.jj	Wed Jan 30 18:03:36 2002
+++ libc/sysdeps/powerpc/elf/libc-start.c	Thu Jan 31 20:44:34 2002
@@ -96,7 +96,7 @@ BP_SYM (__libc_start_main) (int argc, ch
 
   /* Call the initializer of the libc.  */
 #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 libc\n\n");
 #endif
   __libc_init_first (argc, argv, __environ);
@@ -107,14 +107,14 @@ BP_SYM (__libc_start_main) (int argc, ch
 
   /* 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 (stinfo->init)
     stinfo->init (argc, argv, __environ, auxvec);
 
 #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
 
--- libc/sysdeps/powerpc/dl-machine.c.jj	Wed Sep 12 09:57:00 2001
+++ libc/sysdeps/powerpc/dl-machine.c	Thu Jan 31 20:45:53 2002
@@ -112,11 +112,11 @@ __elf_preferred_address(struct link_map 
      be superceded by the program's load address).  */
   low =  0x0003FFFF;
   high = 0x70000000;
-  for (l = _dl_loaded; l; l = l->l_next)
+  for (l = GL(dl_loaded); l; l = l->l_next)
     {
       ElfW(Addr) mapstart, mapend;
-      mapstart = l->l_map_start & ~(_dl_pagesize - 1);
-      mapend = l->l_map_end | (_dl_pagesize - 1);
+      mapstart = l->l_map_start & ~(GL(dl_pagesize) - 1);
+      mapend = l->l_map_end | (GL(dl_pagesize) - 1);
       assert (mapend > mapstart);
 
       /* Prefer gaps below the main executable, note that l ==
@@ -137,7 +137,7 @@ __elf_preferred_address(struct link_map 
     }
 
   high -= 0x10000; /* Allow some room between objects.  */
-  maplength = (maplength | (_dl_pagesize-1)) + 1;
+  maplength = (maplength | (GL(dl_pagesize)-1)) + 1;
   if (high <= low || high - low < maplength )
     return 0;
   return high - maplength;  /* Both high and maplength are page-aligned.  */
@@ -235,10 +235,10 @@ __elf_machine_runtime_setup (struct link
 					 : _dl_runtime_resolve);
 	  Elf32_Word offset;
 
-	  if (profile && _dl_name_match_p (_dl_profile, map))
+	  if (profile && _dl_name_match_p (GL(dl_profile), map))
 	    /* This is the object we are looking for.  Say that we really
 	       want profiling and the timers are started.  */
-	    _dl_profile_map = map;
+	    GL(dl_profile_map) = map;
 
 	  /* For the long entries, subtract off data_words.  */
 	  tramp[0] = OPCODE_ADDIS_HI (11, 11, -data_words);
@@ -467,7 +467,7 @@ __process_machine_rela (struct link_map 
 	   found.  */
 	return;
       if (sym->st_size > refsym->st_size
-	  || (_dl_verbose && sym->st_size < refsym->st_size))
+	  || (GL(dl_verbose) && sym->st_size < refsym->st_size))
 	{
 	  const char *strtab;
 
--- libc/sysdeps/powerpc/dl-start.S.jj	Thu Aug 23 18:50:13 2001
+++ libc/sysdeps/powerpc/dl-start.S	Thu Jan 31 20:47:41 2002
@@ -52,7 +52,7 @@ ENTRY(_dl_start_user)
 /*  the address of _start in r30, */
 	mr	r30,r3
 /*  &_dl_argc in 29, &_dl_argv in 27, and _dl_loaded in 28.  */
-	lwz	r28,_dl_loaded@got(r31)
+	lwz	r28,_rtld_global@got(r31)
 	lwz	r29,_dl_argc@got(r31)
 	lwz	r27,_dl_argv@got(r31)
 
--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj	Thu Dec 27 20:58:51 2001
+++ libc/sysdeps/sparc/sparc32/dl-machine.h	Thu Jan 31 20:51:15 2002
@@ -44,7 +44,7 @@
 
 /* Use a different preload file when running in 32-bit emulation mode
    on a 64-bit host.  */
-#define LD_SO_PRELOAD ((_dl_hwcap & HWCAP_SPARC_V9) ? "/etc/ld.so.preload32" \
+#define LD_SO_PRELOAD ((GL(dl_hwcap) & HWCAP_SPARC_V9) ? "/etc/ld.so.preload32" \
 		       : "/etc/ld.so.preload")
 
 
@@ -57,13 +57,15 @@ elf_machine_matches_host (const Elf32_Eh
   else if (ehdr->e_machine == EM_SPARC32PLUS)
     {
       unsigned long *hwcap;
+#ifndef SHARED
       weak_extern (_dl_hwcap);
       weak_extern (_dl_hwcap_mask);
+#endif
 
-      hwcap = WEAKADDR(_dl_hwcap);
+      hwcap = WEAKADDR(GL(dl_hwcap));
       /* XXX The following is wrong!  Dave Miller rejected to implement it
 	 correctly.  If this causes problems shoot *him*!  */
-      return hwcap == NULL || (*hwcap & _dl_hwcap_mask & HWCAP_SPARC_V9);
+      return hwcap == NULL || (*hwcap & GL(dl_hwcap_mask) & HWCAP_SPARC_V9);
     }
   else
     return 0;
@@ -124,8 +126,8 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  rfunc = (Elf32_Addr) &_dl_runtime_profile;
 
-	  if (_dl_name_match_p (_dl_profile, l))
-	    _dl_profile_map = l;
+	  if (_dl_name_match_p (GL(dl_profile), l))
+	    GL(dl_profile_map) = l;
 	}
 
       /* The beginning of the PLT does:
@@ -154,8 +156,10 @@ elf_machine_runtime_setup (struct link_m
 	  Elf32_Rela *relaend
 	    = (Elf32_Rela *) ((char *) rela
 			      + l->l_info[DT_PLTRELSZ]->d_un.d_val);
+#ifndef SHARED
 	  weak_extern (_dl_hwcap);
-	  hwcap = WEAKADDR(_dl_hwcap);
+#endif
+	  hwcap = WEAKADDR(GL(dl_hwcap));
 	  do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
 
 	  /* prelink must ensure there are no R_SPARC_NONE relocs left
@@ -307,9 +311,9 @@ _dl_start_user:
 	bne	23b
 	 add	%i1, 8, %i1
   /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp.  */
-3:	sethi	%hi(_dl_loaded), %o0
+3:	sethi	%hi(_rtld_global), %o0
 	add	%sp, 23*4, %o2
-	orcc	%o0, %lo(_dl_loaded), %o0
+	orcc	%o0, %lo(_rtld_global), %o0
 	sll	%i5, 2, %o3
 	ld	[%l7+%o0], %o0
 	add	%o3, 4, %o3
@@ -337,8 +341,10 @@ sparc_fixup_plt (const Elf32_Rela *reloc
      functionality on those cpu's that implement it.  */
   unsigned long *hwcap;
   int do_flush;
+#ifndef SHARED
   weak_extern (_dl_hwcap);
-  hwcap = WEAKADDR(_dl_hwcap);
+#endif
+  hwcap = WEAKADDR(GL(dl_hwcap));
   do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
 #else
   /* Unfortunately, this is necessary, so that we can ensure
@@ -451,7 +457,7 @@ elf_machine_rela (struct link_map *map, 
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (_dl_verbose && sym->st_size < refsym->st_size))
+	      || (GL(dl_verbose) && sym->st_size < refsym->st_size))
 	    {
 	      extern char **_dl_argv;
 	      const char *strtab;
--- libc/sysdeps/sparc/sparc64/dl-machine.h.jj	Thu Dec 27 20:58:51 2001
+++ libc/sysdeps/sparc/sparc64/dl-machine.h	Thu Jan 31 20:52:28 2002
@@ -284,7 +284,7 @@ elf_machine_rela (struct link_map *map, 
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (_dl_verbose && sym->st_size < refsym->st_size))
+	      || (GL(dl_verbose) && sym->st_size < refsym->st_size))
 	    {
 	      extern char **_dl_argv;
 	      const char *strtab;
@@ -498,8 +498,8 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  res0_addr = (Elf64_Addr) &_dl_runtime_profile_0;
 	  res1_addr = (Elf64_Addr) &_dl_runtime_profile_1;
-	  if (_dl_name_match_p (_dl_profile, l))
-	    _dl_profile_map = l;
+	  if (_dl_name_match_p (GL(dl_profile), l))
+	    GL(dl_profile_map) = l;
 	}
 
       /* PLT0 looks like:
@@ -745,9 +745,9 @@ elf_machine_runtime_setup (struct link_m
 "	 add	%i1, 16, %i1\n"						\
 "	stx	%l5, [%l4]\n"						\
 "  /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp.  */\n"	\
-"2:	sethi	%hi(_dl_loaded), %o0\n"					\
+"2:	sethi	%hi(_rtld_global), %o0\n"				\
 "	add	%sp, " __S(STACK_BIAS) " + 23*8, %o2\n"			\
-"	orcc	%o0, %lo(_dl_loaded), %o0\n"				\
+"	orcc	%o0, %lo(_rtld_global), %o0\n"				\
 "	sllx	%i5, 3, %o3\n"						\
 "	ldx	[%l7 + %o0], %o0\n"					\
 "	add	%o3, 8, %o3\n"						\
--- libc/sysdeps/sh/dl-machine.h.jj	Thu Dec 27 20:58:50 2001
+++ libc/sysdeps/sh/dl-machine.h	Thu Jan 31 20:54:53 2002
@@ -105,7 +105,7 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  got[2] = (Elf32_Addr) &_dl_runtime_profile;
 	  /* 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
@@ -388,7 +388,7 @@ _dl_start_user:\n\
 .L_dl_init:\n\
 	.long _dl_init@PLT\n\
 .L_dl_loaded:\n\
-	.long _dl_loaded@GOT\n\
+	.long _rtld_global@GOT\n\
 .L_dl_starting_up:\n\
 	.long _dl_starting_up@GOT\n\
 .L_dl_fini:\n\
@@ -411,14 +411,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
@@ -481,7 +479,7 @@ elf_machine_rela (struct link_map *map, 
   if (__builtin_expect (r_type == R_SH_RELATIVE, 0))
     {
 #ifndef RTLD_BOOTSTRAP
-      if (map != &_dl_rtld_map) /* Already done in rtld itself.	 */
+      if (map != &GL(dl_rtld_map)) /* Already done in rtld itself.	 */
 #endif
 	{
 	  if (reloc->r_addend)
@@ -515,7 +513,7 @@ elf_machine_rela (struct link_map *map, 
 	       found.  */
 	    break;
 	  if (sym->st_size > refsym->st_size
-	      || (sym->st_size < refsym->st_size && _dl_verbose))
+	      || (sym->st_size < refsym->st_size && GL(dl_verbose)))
 	    {
 	      const char *strtab;
 
@@ -542,8 +540,10 @@ elf_machine_rela (struct link_map *map, 
 	      compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
 	      rtld.c contains the common defn for _dl_rtld_map, which
 	      is incompatible with a weak decl in the same file.  */
+#ifndef SHARED
 	    weak_extern (_dl_rtld_map);
-	    if (map == &_dl_rtld_map)
+#endif
+	    if (map == &GL(dl_rtld_map))
 	      /* Undo the relocation done here during bootstrapping.
 		 Now we will relocate it anew, possibly using a
 		 binding found in the user program or a loaded library
--- libc/sysdeps/s390/s390-32/dl-machine.h.jj	Wed Jan 30 18:03:37 2002
+++ libc/sysdeps/s390/s390-32/dl-machine.h	Thu Jan 31 20:56:10 2002
@@ -112,10 +112,10 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  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
@@ -287,7 +287,7 @@ _dl_start_user:\n\
 	# Call the function to run the initializers.\n\
 	# Load the parameters:\n\
 	# (%r2, %r3, %r4, %r5) = (_dl_loaded, argc, argv, envp)\n\
-	l     %r2,_dl_loaded@GOT(%r12)\n\
+	l     %r2,_rtld_global@GOT(%r12)\n\
 	l     %r2,0(%r2)\n\
 	l     %r3,96(%r15)\n\
 	la    %r4,100(%r15)\n\
@@ -333,14 +333,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
@@ -401,7 +399,7 @@ elf_machine_rela (struct link_map *map, 
 	    break;
 	  if (__builtin_expect (sym->st_size > refsym->st_size, 0)
 	      || (__builtin_expect (sym->st_size < refsym->st_size, 0)
-		  && __builtin_expect (_dl_verbose, 0)))
+		  && __builtin_expect (GL(dl_verbose), 0)))
 	    {
 	      const char *strtab;
 
--- libc/sysdeps/s390/s390-64/dl-machine.h.jj	Wed Jan 30 18:03:38 2002
+++ libc/sysdeps/s390/s390-64/dl-machine.h	Thu Jan 31 20:57:14 2002
@@ -105,10 +105,10 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  got[2] = (Elf64_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
@@ -262,7 +262,7 @@ _dl_start_user:\n\
 	# Call the function to run the initializers.\n\
 	# Load the parameters:\n\
 	# (%r2, %r3, %r4, %r5) = (_dl_loaded, argc, argv, envp)\n\
-	lghi  %r2,_dl_loaded@GOT
+	lghi  %r2,_rtld_global@GOT
 	lg    %r2,0(%r2,%r12)\n\
 	lg    %r2,0(%r2)\n\
 	lg    %r3,160(%r15)\n\
@@ -302,14 +302,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 Elf64_Addr
@@ -369,7 +367,7 @@ elf_machine_rela (struct link_map *map, 
 	    break;
 	  if (__builtin_expect (sym->st_size > refsym->st_size, 0)
 	      || (__builtin_expect (sym->st_size < refsym->st_size, 0)
-		  && __builtin_expect (_dl_verbose, 0)))
+		  && __builtin_expect (GL(dl_verbose), 0)))
 	    {
 	      const char *strtab;
 
--- libc/sysdeps/unix/sysv/aix/libc-start.c.jj	Thu Sep 27 23:22:27 2001
+++ libc/sysdeps/unix/sysv/aix/libc-start.c	Thu Jan 31 21:01:18 2002
@@ -73,10 +73,6 @@ extern int __loadx (int flag, void *modu
 /* Needed by setenv */
 char  **__environ;
 
-/* Needed by dl-support.c */
-/* XXX stubbing out dl-support.c for now..
-   size_t _dl_pagesize = 0; */
-
 /*
  * Find __rtinit symbol
  *
@@ -277,7 +273,7 @@ __libc_start_main (void)
 
   /* 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",
 		      __libc_start_data.argv[0]);
 #endif
@@ -285,7 +281,7 @@ __libc_start_main (void)
     (*__libc_start_data.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",
 		      __libc_start_data.argv[0]);
 #endif
--- libc/sysdeps/unix/sysv/aix/start-libc.c.jj	Sat Sep  8 19:41:25 2001
+++ libc/sysdeps/unix/sysv/aix/start-libc.c	Thu Jan 31 21:01:39 2002
@@ -74,10 +74,6 @@ extern int __loadx (int flag, void *modu
 /* Needed by setenv */
 char  **__environ;
 
-/* Needed by dl-support.c */
-/* XXX stubbing out dl-support.c for now..
-   size_t _dl_pagesize = 0; */
-
 /*
    Find __rtinit symbol
 
--- libc/sysdeps/unix/sysv/linux/ia64/dl-static.c.jj	Thu Jan 31 11:40:33 2002
+++ libc/sysdeps/unix/sysv/linux/ia64/dl-static.c	Thu Jan 31 21:03:41 2002
@@ -19,8 +19,6 @@
 
 #include <ldsodefs.h>
 
-extern int _dl_clktck;
-
 #ifdef SHARED
 
 void
--- libc/sysdeps/unix/sysv/linux/m68k/getpagesize.c.jj	Thu Aug 23 18:51:06 2001
+++ libc/sysdeps/unix/sysv/linux/m68k/getpagesize.c	Thu Jan 31 21:04:59 2002
@@ -19,6 +19,7 @@
 
 #include <unistd.h>
 #include <sys/param.h>
+#include <lssodefs.h>
 #include <errno.h>
 
 #include <sysdep.h>
@@ -28,13 +29,12 @@
 int
 __getpagesize ()
 {
-  extern size_t _dl_pagesize;
 #ifdef __NR_getpagesize
   int result;
 #endif
 
-  if (_dl_pagesize != 0)
-    return _dl_pagesize;
+  if (GL(dl_pagesize) != 0)
+    return GL(dl_pagesize);
 
 #ifdef __NR_getpagesize
   result = INLINE_SYSCALL (getpagesize, 0);
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/getpagesize.c.jj	Thu Aug 23 18:51:33 2001
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/getpagesize.c	Thu Jan 31 21:05:47 2002
@@ -18,6 +18,7 @@
 
 #include <unistd.h>
 #include <sys/param.h>
+#include <ldsodefs.h>
 
 /* Return the system page size.  This value will either be 4k or 8k depending
    on whether or not we are running on Sparc v9 machine.  */
@@ -26,16 +27,14 @@
    via the AT_PAGESZ auxiliary argument.  If we are a static program, we
    use the getpagesize system call.  */
 
-size_t _dl_pagesize;
-
 extern size_t __syscall_getpagesize(void);
 
 int
 __getpagesize ()
 {
-  if (_dl_pagesize == 0)
-    _dl_pagesize = __syscall_getpagesize();
-  return _dl_pagesize;
+  if (GL(dl_pagesize) == 0)
+    GL(dl_pagesize) = __syscall_getpagesize();
+  return GL(dl_pagesize);
 }
 
 weak_alias (__getpagesize, getpagesize)
--- libc/sysdeps/x86_64/dl-machine.h.jj	Thu Dec 27 20:58:52 2001
+++ libc/sysdeps/x86_64/dl-machine.h	Thu Jan 31 20:58:59 2002
@@ -96,10 +96,10 @@ elf_machine_runtime_setup (struct link_m
 	{
 	  got[2] = (Elf64_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
@@ -250,7 +250,7 @@ _dl_start_user:\n\
 	# argc -> rsi\n\
 	movq %rdx, %rsi\n\
 	# _dl_loaded -> rdi\n\
-	movq _dl_loaded@GOTPCREL(%rip), %rdi\n\
+	movq _rtld_global@GOTPCREL(%rip), %rdi\n\
 	movq (%rdi), %rdi\n\
 	# env -> rcx\n\
 	leaq 16(%rsp,%rdx,8), %rcx\n\
@@ -283,14 +283,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 Elf64_Addr
@@ -334,8 +332,10 @@ elf_machine_rela (struct link_map *map, 
 	 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
 	 common defn for _dl_rtld_map, which is incompatible with a
 	 weak decl in the same file.  */
+#ifndef SHARED
       weak_extern (_dl_rtld_map);
-      if (map != &_dl_rtld_map) /* Already done in rtld itself.  */
+#endif
+      if (map != &GL(dl_rtld_map)) /* Already done in rtld itself.  */
 # endif
 	*reloc_addr = map->l_addr + reloc->r_addend;
     }
@@ -379,7 +379,7 @@ elf_machine_rela (struct link_map *map, 
 	    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;
 


	Jakub


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