summaryrefslogtreecommitdiff
path: root/libexec/ld.so/alpha/rtld_machine.c
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/ld.so/alpha/rtld_machine.c')
-rw-r--r--libexec/ld.so/alpha/rtld_machine.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c
index e9c67279577..41eeb010bdb 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.20 2003/01/17 20:41:07 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.21 2003/02/15 22:39:13 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -208,7 +208,7 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
*((int *)0) = 0; /* XXX */
}
/* if PLT is protected, allow the write */
- if (object->plt_addr != NULL && object->plt_size != 0) {
+ if (object->plt_size != 0) {
sigfillset(&nmask);
_dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
_dl_mprotect(addr, sizeof(Elf_Addr),
@@ -218,7 +218,7 @@ _dl_bind(elf_object_t *object, Elf_Word reloff)
*addr = ooff + this->st_value + rela->r_addend;
/* if PLT is (to be protected, change back to RO/X */
- if (object->plt_addr != NULL && object->plt_size != 0) {
+ if (object->plt_size != 0) {
_dl_mprotect(addr, sizeof(Elf_Addr),
PROT_READ|PROT_EXEC);
_dl_sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -236,11 +236,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
Elf_Addr *pltgot;
extern void _dl_bind_start(void); /* XXX */
Elf_Addr ooff;
+ Elf_Addr plt_addr;
const Elf_Sym *this;
pltgot = (Elf_Addr *)object->Dyn.info[DT_PLTGOT];
+ object->got_addr = NULL;
+ object->got_size = 0;
this = NULL;
ooff = _dl_find_symbol("__got_start", object, &this,
SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, SYM_NOTPLT,
@@ -255,19 +258,38 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
if (this != NULL)
object->got_size = ooff + this->st_value - object->got_addr;
+ plt_addr = NULL;
+ object->plt_size = 0;
this = NULL;
ooff = _dl_find_symbol("__plt_start", object, &this,
SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, SYM_NOTPLT,
NULL);
if (this != NULL)
- object->plt_addr = ooff + this->st_value;
+ plt_addr = ooff + this->st_value;
this = NULL;
ooff = _dl_find_symbol("__plt_end", object, &this,
SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, SYM_NOTPLT,
NULL);
if (this != NULL)
- object->plt_size = ooff + this->st_value - object->plt_addr;
+ object->plt_size = ooff + this->st_value - plt_addr;
+
+ if (object->got_addr == NULL)
+ object->got_start = NULL;
+ else {
+ object->got_start = ELF_TRUNC(object->got_addr, _dl_pagesz);
+ object->got_size += object->got_addr - object->got_start;
+ object->got_size = ELF_ROUND(object->got_size, _dl_pagesz);
+ }
+ if (plt_addr == NULL)
+ object->plt_start = NULL;
+ else {
+ object->plt_start = ELF_TRUNC(plt_addr, _dl_pagesz);
+ object->plt_size += plt_addr - object->plt_start;
+ object->plt_size = ELF_ROUND(object->plt_size, _dl_pagesz);
+ }
+
+
if (object->obj_type == OBJTYPE_LDR || !lazy || pltgot == NULL) {
_dl_md_reloc(object, DT_JMPREL, DT_PLTRELSZ);
@@ -293,8 +315,8 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
if (object->got_addr != NULL && object->got_size != 0)
_dl_mprotect((void*)object->got_addr, object->got_size,
PROT_READ|PROT_EXEC);
- if (object->plt_addr != NULL && object->got_size != 0)
- _dl_mprotect((void*)object->plt_addr, object->plt_size,
+ if (object->got_size != 0)
+ _dl_mprotect((void*)object->plt_start, object->plt_size,
PROT_READ|PROT_EXEC);
}