(_dl_map_object_from_fd): Remove use of _dl_pf_to_prot. Use arithmetic operation...
authorUlrich Drepper <drepper@redhat.com>
Sat, 10 Nov 2001 22:43:10 +0000 (22:43 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 10 Nov 2001 22:43:10 +0000 (22:43 +0000)
elf/dl-load.c

index fe552e8..0bc01ec 100644 (file)
@@ -131,18 +131,6 @@ static const struct r_strlenpair *capstr;
 static size_t ncapstr;
 static size_t max_capstrlen;
 
-const unsigned char _dl_pf_to_prot[8] =
-{
-  [0] = PROT_NONE,
-  [PF_R] = PROT_READ,
-  [PF_W] = PROT_WRITE,
-  [PF_R | PF_W] = PROT_READ | PROT_WRITE,
-  [PF_X] = PROT_EXEC,
-  [PF_R | PF_X] = PROT_READ | PROT_EXEC,
-  [PF_W | PF_X] = PROT_WRITE | PROT_EXEC,
-  [PF_R | PF_W | PF_X] = PROT_READ | PROT_WRITE | PROT_EXEC
-};
-
 
 /* Get the generated information about the trusted directories.  */
 #include "trusted-dirs.h"
@@ -926,18 +914,18 @@ _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)
-             c->prot = _dl_pf_to_prot[ph->p_flags & (PF_R | PF_W | PF_X)];
-           else
-             {
-               c->prot = 0;
-               if (ph->p_flags & PF_R)
-                 c->prot |= PROT_READ;
-               if (ph->p_flags & PF_W)
-                 c->prot |= PROT_WRITE;
-               if (ph->p_flags & PF_X)
-                 c->prot |= PROT_EXEC;
-             }
+#if (PF_R | PF_W | PF_X) == 7 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7
+           c->prot = (PF_TO_PROT
+                      >> ((ph->p_flags & (PF_R | PF_W | PF_X)) * 4)) & 0xf;
+#else
+           c->prot = 0;
+           if (ph->p_flags & PF_R)
+             c->prot |= PROT_READ;
+           if (ph->p_flags & PF_W)
+             c->prot |= PROT_WRITE;
+           if (ph->p_flags & PF_X)
+             c->prot |= PROT_EXEC;
+#endif
          }
          break;
        }