about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-07 07:44:06 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-07 07:44:06 +0000
commitfb0356b9d6471b69e0160edacb13845762b2c510 (patch)
treed9b951afc41106624b14d780ab3f20423c9edef7 /elf
parentbd3916e8fb78089adb44cdc7ec8b737e11a9a0d6 (diff)
downloadglibc-fb0356b9d6471b69e0160edacb13845762b2c510.tar.gz
glibc-fb0356b9d6471b69e0160edacb13845762b2c510.tar.xz
glibc-fb0356b9d6471b69e0160edacb13845762b2c510.zip
Update.
2001-11-06  Ulrich Drepper  <drepper@redhat.com>

	* elf/dl-load.c (_dl_map_object_from_fd): Don't call
	_dl_signal_error directly, always use lose.  Set fd to -1 after
	file is closed.
	(lose): Don't call close if fd == -1.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 421a72dfc2..60e7d2e869 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -749,7 +749,9 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
      which use `alloca'.  */
   int *a = alloca (sizeof (int));
   a[0] = fd;
-  (void) __close (a[0]);
+  /* The file might already be closed.  */
+  if (a[0] != -1)
+    (void) __close (a[0]);
   if (l != NULL)
     {
       /* Remove the stillborn object from the list and free it.  */
@@ -921,8 +923,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 	    c->mapoff = ph->p_offset & ~(ph->p_align - 1);
 
 	    /* Optimize a common case.  */
-	    if ((PF_R | PF_W | PF_X) == 7
-		&& (PROT_READ | PROT_WRITE | PROT_EXEC) == 7)
+	    if ((PF_R | PF_W | PF_X) == 7)
 	      c->prot = _dl_pf_to_prot[ph->p_flags & (PF_R | PF_W | PF_X)];
 	    else
 	      {
@@ -1099,6 +1100,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
   /* We are done mapping in the file.  We no longer need the descriptor.  */
   __close (fd);
+  /* Signal that we closed the file.  */
+  fd = -1;
 
   if (l->l_type == lt_library && type == ET_EXEC)
     l->l_type = lt_executable;
@@ -1155,8 +1158,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
       free (l);
 
-      _dl_signal_error (0, name, NULL,
-			N_("shared object cannot be dlopen()ed"));
+      errstring = N_("shared object cannot be dlopen()ed");
+      goto call_lose;
     }
 
   if (l->l_info[DT_HASH])
@@ -1227,13 +1230,9 @@ print_search_path (struct r_search_path_elem **list,
 	      cp[0] = '\0';
 	    else
 	      cp[-1] = '\0';
-	    if (first)
-	      {
-		_dl_debug_printf_c ("%s", buf);
-		first = 0;
-	      }
-	    else
-	      _dl_debug_printf_c (":%s", buf);
+
+	    _dl_debug_printf_c (first ? "%s" : ":%s", buf);
+	    first = 0;
 	  }
 
       ++list;