Make immediate binding work again by actually implementing

_rtld_relocate_plt_objects(). Note that this is for i386 only;
any efforts to make it work on other platforms are left to
those who are using them...
This commit is contained in:
junyoung 2002-09-17 07:29:46 +00:00
parent 0a4b948848
commit 9754fa4d8e
3 changed files with 33 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdreloc.c,v 1.14 2002/09/12 22:56:30 mycroft Exp $ */
/* $NetBSD: mdreloc.c,v 1.15 2002/09/17 07:29:49 junyoung Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@ -204,3 +204,30 @@ _rtld_relocate_plt_object(obj, rela, addrp)
*addrp = (caddr_t)new_value;
return 0;
}
int
_rtld_relocate_plt_objects(const Obj_Entry *obj)
{
const Elf_Rel *rel;
for (rel = obj->pltrel; rel < obj->pltrellim; rel++) {
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
Elf_Addr target;
const Elf_Sym *def;
const Obj_Entry *defobj;
assert(ELF_R_TYPE(rel->r_info) == R_TYPE(JMP_SLOT));
def = _rtld_find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
true);
if (def == NULL)
return -1;
target = (Elf_Addr)(defobj->relocbase + def->st_value);
rdbg(("bind now/fixup in %s --> old=%p new=%p",
defobj->strtab + def->st_name, (void *)*where,
(void *)target));
if (*where != target)
*where = target;
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: reloc.c,v 1.67 2002/09/13 03:09:38 mycroft Exp $ */
/* $NetBSD: reloc.c,v 1.68 2002/09/17 07:29:46 junyoung Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -248,9 +248,9 @@ _rtld_relocate_objects(first, bind_now, self)
}
if (_rtld_relocate_plt_lazy(obj) < 0)
ok = 0;
#if 0
#if defined(__i386__)
if (bind_now)
if (_rtld_relocate_plt_object(obj) < 0)
if (_rtld_relocate_plt_objects(obj) < 0)
ok = 0;
#endif
if (!ok)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld.h,v 1.49 2002/09/13 03:22:08 mycroft Exp $ */
/* $NetBSD: rtld.h,v 1.50 2002/09/17 07:29:47 junyoung Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -265,6 +265,7 @@ int _rtld_relocate_nonplt_objects __P((const Obj_Entry *, bool));
int _rtld_relocate_plt_lazy __P((const Obj_Entry *));
int _rtld_relocate_plt_object __P((const Obj_Entry *, const Elf_Rela *,
caddr_t *));
int _rtld_relocate_plt_objects __P((const Obj_Entry *));
/* search.c */
char *_rtld_find_library __P((const char *, const Obj_Entry *));