diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | elf/dl-reloc.c | 24 | ||||
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 14 |
3 files changed, 33 insertions, 12 deletions
@@ -1,3 +1,10 @@ +2001-11-10 Ulrich Drepper <drepper@redhat.com> + + * elf/dl-load.c (_dl_map_object_from_fd): Remove use of + _dl_pf_to_prot. Use arithmetic operation using PF_TO_PROT macro. + * sysdeps/generic/ldsodefs.h (PF_TO_PROT): New macro. + * elf/dl-reloc.c (_dl_relocate_object): Likewise. + 2001-11-10 Andreas Jaeger <aj@suse.de> * sysdeps/ieee754/ldbl-128/e_log2l.c: New file. diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index efdccea151..da964b7948 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -167,20 +167,20 @@ cannot make segment writable for relocation")); caddr_t mapend = ((caddr_t) l->l_addr + ((ph->p_vaddr + ph->p_memsz + _dl_pagesize - 1) & ~(_dl_pagesize - 1))); - extern unsigned char _dl_pf_to_prot[8]; int prot; - if ((PF_R | PF_W | PF_X) == 7 - && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7) - prot = _dl_pf_to_prot[ph->p_flags & (PF_R | PF_X)]; - else - { - prot = 0; - if (ph->p_flags & PF_R) - prot |= PROT_READ; - if (ph->p_flags & PF_X) - prot |= PROT_EXEC; - } +#if (PF_R | PF_W | PF_X) == 7 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7 + prot = (PF_TO_PROT + >> ((ph->p_flags & (PF_R | PF_W | PF_X)) * 4)) & 0xf; +#else + prot = 0; + if (ph->p_flags & PF_R) + prot |= PROT_READ; + if (ph->p_flags & PF_W) + prot |= PROT_WRITE; + if (ph->p_flags & PF_X) + prot |= PROT_EXEC; +#endif if (__builtin_expect (__mprotect (mapstart, mapend - mapstart, prot), 0) < 0) diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 2a4491d1f9..8c2f160160 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -95,6 +95,20 @@ typedef ElfW(Addr) lookup_t; #define ELF_RTYPE_CLASS_PLT 1 #define ELF_RTYPE_CLASS_COPY 2 +/* ELF uses the PF_x macros to specify the segment permissions, mmap + uses PROT_xxx. In most cases the three macros have the values 1, 2, + and 3 but not in a matching order. The following macros allows + converting from the PF_x values to PROT_xxx values. */ +#define PF_TO_PROT \ + ((PROT_READ << (PF_R * 4)) \ + | (PROT_WRITE << (PF_W * 4)) \ + | (PROT_EXEC << (PF_X * 4)) \ + | ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4)) \ + | ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4)) \ + | ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) \ + | ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4))) + + /* For the version handling we need an array with only names and their hash values. */ struct r_found_version |