-/* $OpenBSD: rtld_machine.c,v 1.32 2015/11/02 07:02:53 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.33 2016/06/21 15:21:42 deraadt Exp $ */
/*
* Copyright (c) 2004 Michael Shalayeff
Elf_Addr loff;
int i, numrela, fails = 0;
size_t size;
+ struct load_list *llist;
loff = object->obj_base;
numrela = object->Dyn.info[relasz] / sizeof(Elf_RelA);
object->dyn.fini = (void *)addr;
}
+ /*
+ * unprotect some segments if we need it.
+ */
+ if ((object->dyn.textrel == 1) && (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,
+ PROT_READ|PROT_WRITE);
+ }
+ }
+
/*
* this is normally done by the crt0 code but we have to make
* sure it's set here to allow constructors to call functions
}
}
+ /* reprotect the unprotected segments */
+ if ((object->dyn.textrel == 1) && (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);
}