about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--elf/rtld.c7
-rw-r--r--posix/unistd.h7
-rw-r--r--sysdeps/i386/dl-machine.h59
4 files changed, 59 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 965df55058..ec8b1c93fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Fri Jul  5 12:22:51 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
+
+	* elf/rtld.c: Define RTLD_BOOTSTRAP before #include "dynamic-link.h".
+	* sysdeps/i386/dl-machine.h (elf_machine_rel): Remove weak decl for
+	_dl_rtld_map.
+	(RESOLVE): New macro, defined differently based on [RTLD_BOOTSTRAP].
+	(elf_machine_rel): Use it instead of testing fn ptr arg at runtime.
+	(elf_machine_rel: case R_386_32) [! RTLD_BOOTSTRAP]: Declare
+	_dl_rtld_map weak only here.
+
+	* posix/unistd.h [__USE_BSD]: Declare getdomainname, setdomainname.
+
 Wed Jul  3 16:29:41 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
 	* nss/getXXbyYY_r.c (REENTRANT_NAME): Cast FCT in __nss_next call.
diff --git a/elf/rtld.c b/elf/rtld.c
index 8ec637f6a8..6baa7a868a 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -18,13 +18,18 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <link.h>
-#include "dynamic-link.h"
 #include <stddef.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include "../stdio-common/_itoa.h"
 
 
+/* This #define produces dynamic linking inline functions for
+   bootstrap relocation instead of general-purpose relocation.  */
+#define RTLD_BOOTSTRAP
+#include "dynamic-link.h"
+
+
 #ifdef RTLD_START
 RTLD_START
 #else
diff --git a/posix/unistd.h b/posix/unistd.h
index 92e874ed5e..0c4ddccb20 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -620,6 +620,13 @@ extern long int gethostid __P ((void));
 extern int sethostid __P ((long int __id));
 
 
+/* Get and set the NIS (aka YP) domain name, if any.
+   Called just like `gethostname' and `sethostname'.
+   The NIS domain name is usually the empty string when not using NIS.  */
+extern int getdomainname __P ((char *__name, size_t __len));
+extern int setdomainname __P ((__const char *__name, size_t __len));
+
+
 /* Return the number of bytes in a page.  This is the system's page size,
    which is not necessarily the same as the hardware page size.  */
 extern size_t __getpagesize __P ((void));
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 406133861d..50e928ce3a 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -79,49 +79,56 @@ elf_machine_rel (struct link_map *map,
 					int noplt))
 {
   Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
-  Elf32_Addr loadbase, undo;
-  weak_symbol (_dl_rtld_map);	/* Defined in rtld.c, but not in libc.a.  */
+  Elf32_Addr loadbase;
+
+#ifdef RTLD_BOOTSTRAP
+#define RESOLVE(noplt) map->l_addr
+#else
+#define RESOLVE(noplt) (*resolve) (&sym, (Elf32_Addr) reloc_addr, noplt)
+#endif
 
   switch (ELF32_R_TYPE (reloc->r_info))
     {
     case R_386_COPY:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (0);
       memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
       break;
     case R_386_GLOB_DAT:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
+      loadbase = RESOLVE (0);
       *reloc_addr = sym ? (loadbase + sym->st_value) : 0;
       break;
     case R_386_JMP_SLOT:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 1) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
+      loadbase = RESOLVE (1);
       *reloc_addr = sym ? (loadbase + sym->st_value) : 0;
       break;
     case R_386_32:
-      if (resolve && map == &_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
-	   built-in definitions used while loading those libraries.  */
-	undo = map->l_addr + sym->st_value;
-      else
-	undo = 0;
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
-      *reloc_addr += (sym ? (loadbase + sym->st_value) : 0) - undo;
-      break;
+      {
+	Elf32_Addr undo = 0;
+#ifndef RTLD_BOOTSTRAP
+	/* 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) because rtld.c contains the common defn for
+	   _dl_rtld_map, which is incompatible with a weak decl in the same
+	   file.  */
+	weak_symbol (_dl_rtld_map);
+	if (map == &_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
+	     built-in definitions used while loading those libraries.  */
+	  undo = map->l_addr + sym->st_value;
+#endif
+	loadbase = RESOLVE (0);
+	*reloc_addr += (sym ? (loadbase + sym->st_value) : 0) - undo;
+	break;
+      }
     case R_386_RELATIVE:
       if (!resolve || map != &_dl_rtld_map) /* Already done in rtld itself.  */
 	*reloc_addr += map->l_addr;
       break;
     case R_386_PC32:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
+      loadbase = RESOLVE (0);
       *reloc_addr += ((sym ? (loadbase + sym->st_value) : 0) -
 		      (Elf32_Addr) reloc_addr);
       break;
@@ -131,6 +138,8 @@ elf_machine_rel (struct link_map *map,
       assert (! "unexpected dynamic reloc type");
       break;
     }
+
+#undef RESOLVE
 }
 
 static inline void