(_dl_map_object_from_fd): Remove use of _dl_pf_to_prot. Use arithmetic operation using PF_TO_PROT macro.

This commit is contained in:
Ulrich Drepper 2001-11-10 22:43:10 +00:00
parent 76321a2576
commit 94a758fe85
1 changed files with 12 additions and 24 deletions

View 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;
}