aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-10 22:43:10 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-10 22:43:10 +0000
commit94a758fe850a09fd39dcb61e49ac9060959f8aa5 (patch)
tree70f0cc172dee0fd81ae4862dfab376ba40d22ea2
parent76321a2576e76e84ea635c46ed16ed61cff6df4b (diff)
downloadglibc-94a758fe850a09fd39dcb61e49ac9060959f8aa5.tar
glibc-94a758fe850a09fd39dcb61e49ac9060959f8aa5.tar.gz
glibc-94a758fe850a09fd39dcb61e49ac9060959f8aa5.tar.bz2
glibc-94a758fe850a09fd39dcb61e49ac9060959f8aa5.zip
(_dl_map_object_from_fd): Remove use of _dl_pf_to_prot. Use arithmetic operation using PF_TO_PROT macro.
-rw-r--r--elf/dl-load.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index fe552e8721..0bc01eca20 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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;
}