about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/dl-machine.h39
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c16
2 files changed, 28 insertions, 27 deletions
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index bfde6662bf..8986ed7d58 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -161,7 +161,14 @@ elf_machine_rela (struct link_map *map,
 {
   Elf64_Addr *const reloc_addr = (void *)(map->l_addr + reloc->r_offset);
   unsigned long r_info = ELF64_R_TYPE (reloc->r_info);
-  weak_symbol (_dl_rtld_map);	/* Defined in rtld.c, but not in libc.a.  */
+#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_extern (_dl_rtld_map);
+#endif
 
   /* We cannot use a switch here because we cannot locate the switch
      jump table until we've self-relocated.  */
@@ -169,38 +176,37 @@ elf_machine_rela (struct link_map *map,
   if (r_info == R_ALPHA_RELATIVE)
     {
       /* Already done in dynamic linker.  */
-      if (!resolve || map != &_dl_rtld_map)
+#ifndef RTLD_BOOTSTRAP
+      if (map != &_dl_rtld_map)
+#endif
 	*reloc_addr += map->l_addr;
     }
   else if (r_info == R_ALPHA_NONE)
-    ;
+    return;
   else
     {
       Elf64_Addr loadbase, sym_value;
 
-      if (resolve)
-	{
-	  loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr,
-				r_info == R_ALPHA_JMP_SLOT);
-	}
-      else
-	loadbase = map->l_addr;
-
+#ifndef RTLD_BOOTSTRAP
+      loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr,
+			    r_info == R_ALPHA_JMP_SLOT);
+#else
+      loadbase = map->l_addr;
+#endif
       sym_value = sym ? loadbase + sym->st_value : 0;
 
       if (r_info == R_ALPHA_GLOB_DAT)
-	{
-	  *reloc_addr = sym_value;
-	}
+	*reloc_addr = sym_value;
       else if (r_info == R_ALPHA_JMP_SLOT)
 	{
 	  *reloc_addr = sym_value;
-	  elf_alpha_fix_plt(map, reloc, (Elf64_Addr)reloc_addr, sym_value);
+	  elf_alpha_fix_plt (map, reloc, (Elf64_Addr) reloc_addr, sym_value);
 	}
       else if (r_info == R_ALPHA_REFQUAD)
 	{
 	  sym_value += *reloc_addr;
-	  if (resolve && map == &_dl_rtld_map)
+#ifndef RTLD_BOOTSTRAP
+	  if (map == &_dl_rtld_map)
 	    {
 	      /* Undo the relocation done here during bootstrapping.
 		 Now we will relocate anew, possibly using a binding
@@ -213,6 +219,7 @@ elf_machine_rela (struct link_map *map,
 	      sym_value -= dlsymtab[ELF64_R_SYM(reloc->r_info)].st_value;
 	    }
 	  else
+#endif
 	    sym_value += reloc->r_addend;
 	  *reloc_addr = sym_value;
 	}
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index ec53e2f36e..cffc51e1ce 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -271,7 +271,7 @@ _dl_sysdep_message (const char *msg, ...)
    dynamic linker re-relocates itself to be user-visible (for -ldl),
    it will get the user's definition (i.e. usually libc's).  */
 
-int
+int weak_function
 __open (const char *file_name, int mode, ...)
 {
   enum retry_type doretry;
@@ -496,7 +496,7 @@ __open (const char *file_name, int mode, ...)
     }
 }
 
-int
+int weak_function
 __close (int fd)
 {
   if (fd != (int) MACH_PORT_NULL)
@@ -504,7 +504,7 @@ __close (int fd)
   return 0;
 }
 
-caddr_t
+caddr_t weak_function
 __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 {
   error_t err;
@@ -546,7 +546,7 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   return err ? (caddr_t) __hurd_fail (err) : (caddr_t) mapaddr;
 }
 
-void
+void weak_function
 _exit (int status)
 {
   __proc_mark_exit (_dl_hurd_data->portarray[INIT_PORT_PROC],
@@ -554,11 +554,6 @@ _exit (int status)
   while (__task_terminate (__mach_task_self ()))
     __mach_task_self_ = (__mach_task_self) ();
 }
-
-weak_symbol (_exit)
-weak_symbol (__open)
-weak_symbol (__close)
-weak_symbol (__mmap)
 
 
 /* This function is called by interruptible RPC stubs.  For initial
@@ -566,7 +561,7 @@ weak_symbol (__mmap)
    weak, the real defn in libc.so will override it if we are linked into
    the user program (-ldl).  */
 
-error_t
+error_t weak_function
 _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
 			 mach_msg_option_t option,
 			 mach_msg_size_t send_size,
@@ -578,4 +573,3 @@ _hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
   return __mach_msg (msg, option, send_size, rcv_size, rcv_name,
 		     timeout, notify);
 }
-weak_symbol (_hurd_intr_rpc_mach_msg)