Support immediate PLT binding on vax. Tested on simh.

Nearly there...
This commit is contained in:
skrll 2005-07-24 08:02:23 +00:00
parent b04d9bdf51
commit 51c5e03c82
2 changed files with 39 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdreloc.c,v 1.17 2003/07/24 10:12:30 skrll Exp $ */
/* $NetBSD: mdreloc.c,v 1.18 2005/07/24 08:02:23 skrll Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@ -9,6 +9,8 @@
void _rtld_bind_start(void);
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
static inline int _rtld_relocate_plt_object(const Obj_Entry *obj,
const Elf_Rela *rela, Elf_Addr *tp);
void
_rtld_setup_pltgot(const Obj_Entry *obj)
@ -137,10 +139,9 @@ _rtld_relocate_plt_lazy(const Obj_Entry *obj)
return 0;
}
caddr_t
_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
static inline int
_rtld_relocate_plt_object(const Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr *tp)
{
const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff);
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
Elf_Addr new_value;
const Elf_Sym *def;
@ -150,7 +151,7 @@ _rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
def = _rtld_find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true);
if (def == NULL)
_rtld_die();
return -1;
new_value = (Elf_Addr)(defobj->relocbase + def->st_value +
rela->r_addend);
@ -159,5 +160,34 @@ _rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
if (*where != new_value)
*where = new_value;
return (caddr_t)(new_value - rela->r_addend);
if (tp)
*tp = new_value - rela->r_addend;
return 0;
}
caddr_t
_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
{
const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff);
Elf_Addr result;
int err;
err = _rtld_relocate_plt_object(obj, rela, &result);
if (err)
_rtld_die();
return (caddr_t)result;
}
int
_rtld_relocate_plt_objects(const Obj_Entry *obj)
{
const Elf_Rela *rela;
for (rela = obj->pltrela; rela < obj->pltrelalim; rela++)
if (_rtld_relocate_plt_object(obj, rela, NULL) < 0)
return -1;
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: reloc.c,v 1.90 2005/07/17 05:57:21 skrll Exp $ */
/* $NetBSD: reloc.c,v 1.91 2005/07/24 08:02:23 skrll Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: reloc.c,v 1.90 2005/07/17 05:57:21 skrll Exp $");
__RCSID("$NetBSD: reloc.c,v 1.91 2005/07/24 08:02:23 skrll Exp $");
#endif /* not lint */
#include <err.h>
@ -192,7 +192,7 @@ _rtld_relocate_objects(Obj_Entry *first, bool bind_now)
#endif
#if defined(__i386__) || defined(__arm__) || defined(__hppa__) \
|| defined(__sparc64__) || defined(__sparc__) || defined(__alpha__) \
|| defined(__sh3__) || defined(__x86_64__)
|| defined(__sh3__) || defined(__x86_64__) || defined(__vax__)
if (bind_now) {
dbg(("doing immediate PLT binding"));
if (_rtld_relocate_plt_objects(obj) < 0)