mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-05 01:00:14 +00:00
Update.
* elf/dl-load.c (_dl_map_object_from_fd): Use global _dl_pf_to_proot array to convert p_flags value. * elf/dl-reloc.c (_dl_relocate_object): Likewise.
This commit is contained in:
parent
57846308af
commit
24d6084042
@ -1,5 +1,9 @@
|
|||||||
1999-02-20 Ulrich Drepper <drepper@cygnus.com>
|
1999-02-20 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd): Use global
|
||||||
|
_dl_pf_to_proot array to convert p_flags value.
|
||||||
|
* elf/dl-reloc.c (_dl_relocate_object): Likewise.
|
||||||
|
|
||||||
* elf/dynamic-link.h (elf_get_dynamic_info): Use memset instead of
|
* elf/dynamic-link.h (elf_get_dynamic_info): Use memset instead of
|
||||||
loop to clear `info'.
|
loop to clear `info'.
|
||||||
|
|
||||||
|
@ -107,6 +107,18 @@ static const struct r_strlenpair *capstr;
|
|||||||
static size_t ncapstr;
|
static size_t ncapstr;
|
||||||
static size_t max_capstrlen;
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* This function has no public prototype. */
|
/* This function has no public prototype. */
|
||||||
extern ssize_t __libc_read (int, void *, size_t);
|
extern ssize_t __libc_read (int, void *, size_t);
|
||||||
@ -782,20 +794,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
|
|||||||
/* Optimize a common case. */
|
/* Optimize a common case. */
|
||||||
if ((PF_R | PF_W | PF_X) == 7
|
if ((PF_R | PF_W | PF_X) == 7
|
||||||
&& (PROT_READ | PROT_WRITE | PROT_EXEC) == 7)
|
&& (PROT_READ | PROT_WRITE | PROT_EXEC) == 7)
|
||||||
{
|
c->prot = _dl_pf_to_prot[ph->p_flags & (PF_R | PF_W | PF_X)];
|
||||||
static const unsigned char 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
|
|
||||||
};
|
|
||||||
c->prot = pf_to_prot[ph->p_flags & (PF_R | PF_W | PF_X)];
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->prot = 0;
|
c->prot = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Relocate a shared object and resolve its references to other loaded objects.
|
/* Relocate a shared object and resolve its references to other loaded objects.
|
||||||
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -108,11 +108,21 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
|||||||
caddr_t mapend = ((caddr_t) l->l_addr +
|
caddr_t mapend = ((caddr_t) l->l_addr +
|
||||||
((ph->p_vaddr + ph->p_memsz + _dl_pagesize - 1)
|
((ph->p_vaddr + ph->p_memsz + _dl_pagesize - 1)
|
||||||
& ~(_dl_pagesize - 1)));
|
& ~(_dl_pagesize - 1)));
|
||||||
int prot = 0;
|
extern unsigned char _dl_pf_to_prot[8];
|
||||||
if (ph->p_flags & PF_R)
|
int prot;
|
||||||
prot |= PROT_READ;
|
|
||||||
if (ph->p_flags & PF_X)
|
if ((PF_R | PF_W | PF_X) == 7
|
||||||
prot |= PROT_EXEC;
|
&& (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 (__mprotect (mapstart, mapend - mapstart, prot) < 0)
|
if (__mprotect (mapstart, mapend - mapstart, prot) < 0)
|
||||||
_dl_signal_error (errno, l->l_name,
|
_dl_signal_error (errno, l->l_name,
|
||||||
"can't restore segment prot after reloc");
|
"can't restore segment prot after reloc");
|
||||||
|
Loading…
Reference in New Issue
Block a user