mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-13 00:30:07 +00:00
(_dl_relocate_object): Move PT_GNU_RELRO protection into... (_dl_protect_relro): New routine.
This commit is contained in:
parent
e151ce7ad3
commit
75631a5763
@ -311,23 +311,25 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
|||||||
/* In case we can protect the data now that the relocations are
|
/* In case we can protect the data now that the relocations are
|
||||||
done, do it. */
|
done, do it. */
|
||||||
if (l->l_relro_size != 0)
|
if (l->l_relro_size != 0)
|
||||||
{
|
_dl_protect_relro (l);
|
||||||
ElfW(Addr) start = ((l->l_addr + l->l_relro_addr)
|
|
||||||
& ~(GL(dl_pagesize) - 1));
|
|
||||||
ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
|
|
||||||
& ~(GL(dl_pagesize) - 1));
|
|
||||||
|
|
||||||
if (start != end
|
|
||||||
&& __mprotect ((void *) start, end - start, PROT_READ) < 0)
|
|
||||||
{
|
|
||||||
errstring = N_("\
|
|
||||||
cannot apply additional memory protection after relocation");
|
|
||||||
goto call_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
INTDEF (_dl_relocate_object)
|
INTDEF (_dl_relocate_object)
|
||||||
|
|
||||||
|
void internal_function
|
||||||
|
_dl_protect_relro (struct link_map *l)
|
||||||
|
{
|
||||||
|
ElfW(Addr) start = ((l->l_addr + l->l_relro_addr) & ~(GL(dl_pagesize) - 1));
|
||||||
|
ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
|
||||||
|
& ~(GL(dl_pagesize) - 1));
|
||||||
|
|
||||||
|
if (start != end
|
||||||
|
&& __mprotect ((void *) start, end - start, PROT_READ) < 0)
|
||||||
|
{
|
||||||
|
const char *errstring = N_("\
|
||||||
|
cannot apply additional memory protection after relocation");
|
||||||
|
INTUSE(_dl_signal_error) (errno, l->l_name, NULL, errstring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
internal_function __attribute_noinline__
|
internal_function __attribute_noinline__
|
||||||
|
Loading…
Reference in New Issue
Block a user