summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2019-08-06 04:01:43 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2019-08-06 04:01:43 +0000
commit21e018dd1b35b1a125508d175c9d88d09329c8a4 (patch)
treecdeb0271b2d6a717d602dbfbf2703e7106381b3d
parent0501f61ae1cebabdc79070fbdfb22a1902d21f6e (diff)
Factor out TEXTREL mprotecting from the per-arch files into _dl_rtld(),
hiding the actual grotty bits in inline functions ok mpi@
-rw-r--r--libexec/ld.so/aarch64/rtld_machine.c27
-rw-r--r--libexec/ld.so/alpha/rtld_machine.c25
-rw-r--r--libexec/ld.so/amd64/rtld_machine.c23
-rw-r--r--libexec/ld.so/arm/rtld_machine.c27
-rw-r--r--libexec/ld.so/hppa/rtld_machine.c23
-rw-r--r--libexec/ld.so/i386/rtld_machine.c23
-rw-r--r--libexec/ld.so/loader.c33
-rw-r--r--libexec/ld.so/m88k/rtld_machine.c28
-rw-r--r--libexec/ld.so/mips64/rtld_machine.c24
-rw-r--r--libexec/ld.so/powerpc/rtld_machine.c25
-rw-r--r--libexec/ld.so/sh/rtld_machine.c27
-rw-r--r--libexec/ld.so/sparc64/rtld_machine.c23
12 files changed, 44 insertions, 264 deletions
diff --git a/libexec/ld.so/aarch64/rtld_machine.c b/libexec/ld.so/aarch64/rtld_machine.c
index 26cd7423591..b539ef3aa1f 100644
--- a/libexec/ld.so/aarch64/rtld_machine.c
+++ b/libexec/ld.so/aarch64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.8 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.9 2019/08/06 04:01:41 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -110,7 +110,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_RelA *rels;
- struct load_list *llist;
loff = object->obj_base;
numrel = object->Dyn.info[relsz] / sizeof(Elf_RelA);
@@ -123,19 +122,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (relrel > numrel)
_dl_die("relcount > numrel: %ld > %ld", relrel, numrel);
- /*
- * 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,
- llist->prot|PROT_WRITE);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, rels++) {
Elf_Addr *where;
@@ -261,17 +247,6 @@ resolve_failed:
}
}
- /* 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);
}
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c
index bc7926dbcb7..c204b5d9636 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.66 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.67 2019/08/06 04:01:41 guenther Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -59,7 +59,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
Elf64_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf64_Rela *relas;
- struct load_list *llist;
loff = object->obj_base;
numrela = object->Dyn.info[relasz] / sizeof(Elf64_Rela);
@@ -75,20 +74,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
if (! object->Dyn.info[DT_PROC(DT_ALPHA_PLTRO)])
_dl_die("unsupported insecure PLT object");
- /*
- * unprotect some segments if we need it.
- * XXX - we unprotect way to much. only the text can have cow
- * relocations.
- */
- 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);
- }
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, relas++) {
Elf_Addr *r_addr;
@@ -189,14 +174,6 @@ resolve_failed:
}
__asm volatile("imb" : : : "memory");
- /* 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);
}
diff --git a/libexec/ld.so/amd64/rtld_machine.c b/libexec/ld.so/amd64/rtld_machine.c
index 012b2cf2eb1..10b808c6c85 100644
--- a/libexec/ld.so/amd64/rtld_machine.c
+++ b/libexec/ld.so/amd64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.32 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.33 2019/08/06 04:01:41 guenther Exp $ */
/*
* Copyright (c) 2002,2004 Dale Rahn
@@ -179,7 +179,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_RelA *rels;
- struct load_list *llist;
loff = object->obj_base;
numrel = object->Dyn.info[relsz] / sizeof(Elf_RelA);
@@ -191,17 +190,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (relrel > numrel)
_dl_die("relacount > numrel: %ld > %ld", relrel, numrel);
- /*
- * 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);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, rels++) {
Elf_Addr *where;
@@ -312,15 +300,6 @@ resolve_failed:
}
}
- /* 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);
}
diff --git a/libexec/ld.so/arm/rtld_machine.c b/libexec/ld.so/arm/rtld_machine.c
index aca7be9552d..60f27505adb 100644
--- a/libexec/ld.so/arm/rtld_machine.c
+++ b/libexec/ld.so/arm/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.29 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.30 2019/08/06 04:01:41 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -171,7 +171,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_Rel *rels;
- struct load_list *llist;
loff = object->obj_base;
numrel = object->Dyn.info[relsz] / sizeof(Elf_Rel);
@@ -184,19 +183,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (relrel > numrel)
_dl_die("relcount > numrel: %ld > %ld", relrel, numrel);
- /*
- * 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);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, rels++) {
Elf_Addr *where;
@@ -324,17 +310,6 @@ resolve_failed:
}
}
- /* 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);
}
diff --git a/libexec/ld.so/hppa/rtld_machine.c b/libexec/ld.so/hppa/rtld_machine.c
index d51e9dcc8a3..c7be3288356 100644
--- a/libexec/ld.so/hppa/rtld_machine.c
+++ b/libexec/ld.so/hppa/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.38 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.39 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 2004 Michael Shalayeff
@@ -106,7 +106,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
Elf_RelA *rela;
Elf_Addr loff;
int i, numrela, fails = 0;
- struct load_list *llist;
loff = object->obj_base;
numrela = object->Dyn.info[relasz] / sizeof(Elf_RelA);
@@ -147,17 +146,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
}
/*
- * 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
* that are overridden in the user binary (that are un-pic)
@@ -298,15 +286,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
}
}
- /* 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);
}
diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c
index 01c7873beae..3a3b441632e 100644
--- a/libexec/ld.so/i386/rtld_machine.c
+++ b/libexec/ld.so/i386/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.40 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.41 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -179,7 +179,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_Rel *rels;
- struct load_list *llist;
loff = object->obj_base;
numrel = object->Dyn.info[relsz] / sizeof(Elf32_Rel);
@@ -191,17 +190,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (relrel > numrel)
_dl_die("relcount > numrel: %ld > %ld", relrel, numrel);
- /*
- * 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);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, rels++) {
Elf_Addr *where;
@@ -325,15 +313,6 @@ resolve_failed:
}
}
- /* 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);
}
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index 918c299aa61..66480ac92de 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.184 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: loader.c,v 1.185 2019/08/06 04:01:41 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -58,6 +58,8 @@ void _dl_fixup_user_env(void) __boot;
void _dl_call_preinit(elf_object_t *) __boot;
void _dl_call_init_recurse(elf_object_t *object, int initfirst);
void _dl_clean_boot(void);
+static inline void unprotect_if_textrel(elf_object_t *_object);
+static inline void reprotect_if_textrel(elf_object_t *_object);
int _dl_pagesz __relro = 4096;
int _dl_bindnow __relro = 0;
@@ -702,8 +704,10 @@ _dl_rtld(elf_object_t *object)
/*
* Do relocation information first, then GOT.
*/
+ unprotect_if_textrel(object);
fails =_dl_md_reloc(object, DT_REL, DT_RELSZ);
fails += _dl_md_reloc(object, DT_RELA, DT_RELASZ);
+ reprotect_if_textrel(object);
fails += _dl_md_reloc_got(object, !(_dl_bindnow ||
object->obj_flags & DF_1_NOW));
@@ -889,3 +893,30 @@ _dl_cb_cb(int version)
return &callbacks_0;
return NULL;
}
+
+static inline void
+unprotect_if_textrel(elf_object_t *object)
+{
+ struct load_list *ll;
+
+ if (__predict_false(object->dyn.textrel == 1)) {
+ for (ll = object->load_list; ll != NULL; ll = ll->next) {
+ if ((ll->prot & PROT_WRITE) == 0)
+ _dl_mprotect(ll->start, ll->size,
+ PROT_READ | PROT_WRITE);
+ }
+ }
+}
+
+static inline void
+reprotect_if_textrel(elf_object_t *object)
+{
+ struct load_list *ll;
+
+ if (__predict_false(object->dyn.textrel == 1)) {
+ for (ll = object->load_list; ll != NULL; ll = ll->next) {
+ if ((ll->prot & PROT_WRITE) == 0)
+ _dl_mprotect(ll->start, ll->size, ll->prot);
+ }
+ }
+}
diff --git a/libexec/ld.so/m88k/rtld_machine.c b/libexec/ld.so/m88k/rtld_machine.c
index 054aacc70d8..a9a62267376 100644
--- a/libexec/ld.so/m88k/rtld_machine.c
+++ b/libexec/ld.so/m88k/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.24 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.25 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 2013 Miodrag Vallat.
@@ -67,7 +67,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
int numrela;
int relrela;
int fails = 0;
- struct load_list *llist;
Elf32_Addr loff;
Elf32_Rela *relas;
Elf32_Addr prev_value = 0, prev_ooff = 0;
@@ -90,21 +89,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
if (relrela > numrela)
_dl_die("relacount > numrel: %d > %d", relrela, numrela);
- /*
- * Change protection of all write protected segments in the object
- * so we can do relocations such as DISP26. After relocation,
- * restore protection.
- */
- 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);
- }
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrela; i++, relas++) {
Elf32_Addr *r_addr;
@@ -231,16 +215,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
}
}
- /* 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);
}
diff --git a/libexec/ld.so/mips64/rtld_machine.c b/libexec/ld.so/mips64/rtld_machine.c
index c2dd8950f25..19e7c65145d 100644
--- a/libexec/ld.so/mips64/rtld_machine.c
+++ b/libexec/ld.so/mips64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.30 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.31 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 1998-2004 Opsycon AB, Sweden.
@@ -65,7 +65,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
int i;
int numrel;
int fails = 0;
- struct load_list *load_list;
Elf64_Addr loff;
Elf64_Rel *relocs;
const Elf64_Sym *sym, *this;
@@ -79,19 +78,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
if (relocs == NULL)
return(0);
- /*
- * Change protection of all write protected segments in the
- * object so we can do relocations in the .rodata section.
- * After relocation restore protection.
- */
- if (object->dyn.textrel) {
- for (load_list = object->load_list; load_list != NULL; load_list = load_list->next) {
- if ((load_list->prot & PROT_WRITE) == 0)
- _dl_mprotect(load_list->start, load_list->size,
- PROT_READ | PROT_WRITE);
- }
- }
-
DL_DEB(("relocating %d\n", numrel));
for (i = 0; i < numrel; i++, relocs++) {
Elf64_Addr r_addr = relocs->r_offset + loff;
@@ -149,14 +135,8 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
ELF64_R_TYPE(relocs->r_info));
}
}
+
DL_DEB(("done %d fails\n", fails));
- if (object->dyn.textrel) {
- for (load_list = object->load_list; load_list != NULL; load_list = load_list->next) {
- if ((load_list->prot & PROT_WRITE) == 0)
- _dl_mprotect(load_list->start, load_list->size,
- load_list->prot);
- }
- }
return(fails);
}
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c
index f0bc44369f5..1e582f2d5e9 100644
--- a/libexec/ld.so/powerpc/rtld_machine.c
+++ b/libexec/ld.so/powerpc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.66 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.67 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -58,7 +58,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
int numrela;
long relrel;
int fails = 0;
- struct load_list *llist;
Elf32_Addr loff;
Elf32_Rela *relas;
/* for jmp table relocations */
@@ -84,20 +83,6 @@ _dl_printf("object relocation size %x, numrela %x\n",
if (object->Dyn.info[DT_PROC(DT_PPC_GOT)] == 0)
_dl_die("unsupported insecure BSS PLT object");
- /*
- * Change protection of all write protected segments in the object
- * so we can do relocations such as REL24, REL16 etc. After
- * relocation restore protection.
- */
- 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);
- }
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, relas++) {
Elf_Addr *r_addr;
@@ -310,14 +295,6 @@ _dl_printf(" found other symbol at %x size %d\n",
}
}
- /* 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);
}
diff --git a/libexec/ld.so/sh/rtld_machine.c b/libexec/ld.so/sh/rtld_machine.c
index 5478f7745ec..d66e2824439 100644
--- a/libexec/ld.so/sh/rtld_machine.c
+++ b/libexec/ld.so/sh/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.28 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.29 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -608,7 +608,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_RelA *rels;
- struct load_list *llist;
loff = object->obj_base;
numrela = object->Dyn.info[relasz] / sizeof(Elf_RelA);
@@ -621,19 +620,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
if (relrel > numrela)
_dl_die("relacount > numrel: %ld > %ld", relrel, numrela);
- /*
- * 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);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, rels++) {
Elf_Addr *where;
@@ -762,17 +748,6 @@ resolve_failed:
}
}
- /* 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);
}
diff --git a/libexec/ld.so/sparc64/rtld_machine.c b/libexec/ld.so/sparc64/rtld_machine.c
index 65ca082a7eb..c47afb71856 100644
--- a/libexec/ld.so/sparc64/rtld_machine.c
+++ b/libexec/ld.so/sparc64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.64 2019/08/04 23:51:45 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.65 2019/08/06 04:01:42 guenther Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -215,7 +215,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
Elf_Addr prev_value = 0;
const Elf_Sym *prev_sym = NULL;
Elf_RelA *relas;
- struct load_list *llist;
loff = object->obj_base;
numrela = object->Dyn.info[relasz] / sizeof(Elf64_Rela);
@@ -228,17 +227,6 @@ _dl_md_reloc(elf_object_t *object, int rel, int relasz)
if (relrel > numrela)
_dl_die("relacount > numrel: %ld > %ld", relrel, numrela);
- /*
- * 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);
- }
- }
-
/* tight loop for leading RELATIVE relocs */
for (i = 0; i < relrel; i++, relas++) {
Elf_Addr *where;
@@ -353,15 +341,6 @@ resolve_failed:
}
}
- /* 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);
}