From 94a758fe850a09fd39dcb61e49ac9060959f8aa5 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 10 Nov 2001 22:43:10 +0000 Subject: [PATCH] (_dl_map_object_from_fd): Remove use of _dl_pf_to_prot. Use arithmetic operation using PF_TO_PROT macro. --- elf/dl-load.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index fe552e8..0bc01ec 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; } -- 2.7.4