diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-31 13:49:28 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-05-31 13:49:28 +0000 |
commit | bb0dbf9e6f8d86857d8dd22e6790635366a8896a (patch) | |
tree | ea121cb80fee0312d1af957b625ba70f8450d522 /libexec | |
parent | 023702efa23c78a4bfd2348111d11158679ab89b (diff) |
Remove write protection from some memory segments when
doing rel and rela relocations.
XXX - we have to find out when and why we actually need it.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/alpha/rtld_machine.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c index dfdb2ac92a9..9ebaa53ba1d 100644 --- a/libexec/ld.so/alpha/rtld_machine.c +++ b/libexec/ld.so/alpha/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.2 2001/05/31 13:26:51 art Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.3 2001/05/31 13:49:27 art Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -37,6 +37,7 @@ #include <sys/types.h> #include <sys/cdefs.h> +#include <sys/mman.h> #include <machine/elf_machdep.h> @@ -67,6 +68,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) long fails = 0; Elf64_Addr loff; Elf64_Rela *relas; + load_list_t *llist; loff = object->load_offs; numrela = object->Dyn.info[relasz] / sizeof(Elf64_Rela); @@ -76,6 +78,20 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz) return(0); } + /* + * unprotect some segments if we need it. + * XXX - we unprotect waay to much. only the text can have cow + * relocations. + */ + if ((rel == DT_REL || rel == DT_RELA)) { + for (llist = object->load_list; llist != NULL; llist = llist->next) { + if (!(llist->prot & PROT_WRITE)) { + _dl_mprotect(llist->start, llist->size, + llist->prot|PROT_WRITE); + } + } + } + for (i = 0; i < numrela; i++, relas++) { Elf64_Addr *r_addr; Elf64_Addr ooff; @@ -188,7 +204,18 @@ resolve_failed: fails++; } __asm __volatile("imb" : : : "memory"); - return(fails); + + /* reprotect the unprotected segments */ + if ((rel == DT_REL || rel == DT_RELA)) { + for (llist = object->load_list; llist != NULL; llist = llist->next) { + if (!(llist->prot & PROT_WRITE)) { + _dl_mprotect(llist->start, llist->size, + llist->prot); + } + } + } + + return (fails); } /* |