diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-08-06 09:38:30 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-08-06 09:38:30 +0000 |
commit | 2e22b27d84a94c0ff54f5fee64ecaea882b5a1f5 (patch) | |
tree | 29ff6eab596db52f4c007f4220e37f91e49a9db2 /libexec | |
parent | b9c5540615588f3d4a9688ab2791cbdc47ce24a4 (diff) |
update for mips
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/mips/rtld_machine.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/libexec/ld.so/mips/rtld_machine.c b/libexec/ld.so/mips/rtld_machine.c index 1f466a3e28a..3ed2da7c971 100644 --- a/libexec/ld.so/mips/rtld_machine.c +++ b/libexec/ld.so/mips/rtld_machine.c @@ -1,7 +1,7 @@ -/* $OpenBSD: rtld_machine.c,v 1.15 2004/05/25 18:07:20 mickey Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.16 2004/08/06 09:38:29 pefo Exp $ */ /* - * Copyright (c) 1998-2002 Opsycon AB, Sweden. + * Copyright (c) 1998-2004 Opsycon AB, Sweden. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,6 +29,7 @@ #define _DYN_LOADER #include <sys/types.h> +#include <sys/mman.h> #include <link.h> #include "resolve.h" @@ -121,11 +122,10 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) Elf32_Addr loff; Elf32_Addr ooff; Elf32_Addr *gotp; + Elf32_Addr plt_addr; const Elf32_Sym *symp; const Elf32_Sym *this; const char *strt; - Elf_Addr ooff; - const Elf_Sym *this; if (object->status & STAT_GOT_DONE) return; @@ -136,6 +136,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) gotp = object->dyn.pltgot; n = object->Dyn.info[DT_MIPS_LOCAL_GOTNO - DT_LOPROC + DT_NUM]; + DL_DEB(("loff: '%p'\n", loff)); /* * Set up pointers for run time (lazy) resolving. */ @@ -147,6 +148,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) /* First do all local references. */ for (i = ((gotp[1] & 0x80000000) ? 2 : 1); i < n; i++) { gotp[i] += loff; + DL_DEB(("got: '%p' = %x\n", &gotp[i], gotp[i])); } gotp += n; @@ -156,11 +158,14 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) n = object->Dyn.info[DT_MIPS_SYMTABNO - DT_LOPROC + DT_NUM] - object->Dyn.info[DT_MIPS_GOTSYM - DT_LOPROC + DT_NUM]; + plt_addr = 0; this = NULL; + object->plt_size = 0; + object->got_size = 0; ooff = _dl_find_symbol("__got_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) - object->got_addr = ooff + this->st_value; + object->got_start = ooff + this->st_value; this = NULL; ooff = _dl_find_symbol("__got_end", object, &this, NULL, @@ -172,13 +177,13 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) ooff = _dl_find_symbol("__plt_start", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) - object->plt_addr = ooff + this->st_value; + object->plt_start = ooff + this->st_value; this = NULL; ooff = _dl_find_symbol("__plt_end", object, &this, NULL, SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object); if (this != NULL) - object->plt_size = ooff + this->st_value - object->plt_addr; + object->plt_size = ooff + this->st_value - plt_addr; /* * Then do all global references according to the ABI. @@ -187,7 +192,7 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) while (n--) { if (symp->st_shndx == SHN_UNDEF && ELF32_ST_TYPE(symp->st_info) == STT_FUNC) { -DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value)); + DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value)); if (symp->st_value == 0 || !lazy) { this = 0; ooff = _dl_find_symbol(strt + symp->st_name, @@ -217,10 +222,10 @@ DL_DEB(("got: '%s' = %x\n", strt + symp->st_name, symp->st_value)); } object->status |= STAT_GOT_DONE; - if (object->got_addr != NULL && object->got_size != 0) - _dl_mprotect((void*)object->got_addr, object->got_size, + if (object->got_size != 0) + _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ); - if (object->plt_addr != NULL && object->plt_size != 0) - _dl_mprotect((void*)object->plt_addr, object->plt_size, + if (object->plt_size != 0) + _dl_mprotect((void*)object->plt_start, object->plt_size, PROT_READ|PROT_EXEC); } |