diff options
| author | skrll <skrll@NetBSD.org> | 2006-03-04 08:58:46 +0000 |
|---|---|---|
| committer | skrll <skrll@NetBSD.org> | 2006-03-04 08:58:46 +0000 |
| commit | 125d6a43ac0ca241f07fb9093fcaaa30ecaa7cc7 (patch) | |
| tree | 1df146602834c6ada37ae513a1848b13c109c712 /libexec | |
| parent | 8ea3cb44c663013ee83c37d031c2ffa70215ae13 (diff) | |
Add LD_BIND_NOW support for mips.
This is the last arch to be done so remove the large ugly #if defined()
stuff in reloc.c.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/arch/mips/mips_reloc.c | 56 | ||||
| -rw-r--r-- | libexec/ld.elf_so/reloc.c | 9 |
2 files changed, 48 insertions, 17 deletions
diff --git a/libexec/ld.elf_so/arch/mips/mips_reloc.c b/libexec/ld.elf_so/arch/mips/mips_reloc.c index cdd5b0a7e07..89f1fe403ee 100644 --- a/libexec/ld.elf_so/arch/mips/mips_reloc.c +++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mips_reloc.c,v 1.49 2005/12/24 20:59:30 perry Exp $ */ +/* $NetBSD: mips_reloc.c,v 1.50 2006/03/04 08:58:46 skrll Exp $ */ /* * Copyright 1997 Michael L. Hitch <mhitch@montana.edu> @@ -30,7 +30,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mips_reloc.c,v 1.49 2005/12/24 20:59:30 perry Exp $"); +__RCSID("$NetBSD: mips_reloc.c,v 1.50 2006/03/04 08:58:46 skrll Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -338,22 +338,58 @@ _rtld_relocate_plt_lazy(const Obj_Entry *obj) return 0; } -caddr_t -_rtld_bind(Elf_Word a0, Elf_Addr a1, Elf_Addr a2, Elf_Addr a3) +static inline int +_rtld_relocate_plt_object(const Obj_Entry *obj, Elf_Word sym, Elf_Addr *tp) { - Elf_Addr *got = (Elf_Addr *)(a2 - 0x7ff0); - const Obj_Entry *obj = (Obj_Entry *)(got[1] & 0x7fffffff); + Elf_Addr *got = obj->pltgot; const Elf_Sym *def; const Obj_Entry *defobj; Elf_Addr new_value; - def = _rtld_find_symdef(a0, obj, &defobj, true); + def = _rtld_find_symdef(sym, obj, &defobj, true); if (def == NULL) - _rtld_die(); + return -1; new_value = (Elf_Addr)(defobj->relocbase + def->st_value); rdbg(("bind now/fixup in %s --> new=%p", defobj->strtab + def->st_name, (void *)new_value)); - got[obj->local_gotno + a0 - obj->gotsym] = new_value; - return ((caddr_t)new_value); + got[obj->local_gotno + sym - obj->gotsym] = new_value; + + if (tp) + *tp = new_value; + return 0; +} + + + + + +caddr_t +_rtld_bind(Elf_Word a0, Elf_Addr a1, Elf_Addr a2, Elf_Addr a3) +{ + Elf_Addr *got = (Elf_Addr *)(a2 - 0x7ff0); + const Obj_Entry *obj = (Obj_Entry *)(got[1] & 0x7fffffff); + Elf_Addr new_value; + int err; + + err = _rtld_relocate_plt_object(obj, a0, &new_value); + if (err) + _rtld_die(); + + return (caddr_t)new_value; +} + +int +_rtld_relocate_plt_objects(const Obj_Entry *obj) +{ + const Elf_Sym *sym = obj->symtab + obj->gotsym; + int i; + + for (i = obj->gotsym; i < obj->symtabno; i++, sym++) { + if (ELF_ST_TYPE(sym->st_info) == STT_FUNC) + if (_rtld_relocate_plt_object(obj, i, NULL) < 0) + return -1; + } + + return 0; } diff --git a/libexec/ld.elf_so/reloc.c b/libexec/ld.elf_so/reloc.c index 3e759eb61f0..9ad9a814bb3 100644 --- a/libexec/ld.elf_so/reloc.c +++ b/libexec/ld.elf_so/reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: reloc.c,v 1.94 2005/07/28 12:35:21 skrll Exp $ */ +/* $NetBSD: reloc.c,v 1.95 2006/03/04 08:58:46 skrll Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -39,7 +39,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: reloc.c,v 1.94 2005/07/28 12:35:21 skrll Exp $"); +__RCSID("$NetBSD: reloc.c,v 1.95 2006/03/04 08:58:46 skrll Exp $"); #endif /* not lint */ #include <err.h> @@ -190,16 +190,11 @@ _rtld_relocate_objects(Obj_Entry *first, bool bind_now) #if defined(__hppa__) bind_now = 1; #endif -#if defined(__i386__) || defined(__arm__) || defined(__hppa__) \ - || defined(__sparc64__) || defined(__sparc__) || defined(__alpha__) \ - || defined(__sh__) || defined(__x86_64__) || defined(__vax__) \ - || defined(__m68k__) || defined(__powerpc__) if (bind_now) { dbg(("doing immediate PLT binding")); if (_rtld_relocate_plt_objects(obj) < 0) ok = 0; } -#endif if (!ok) return -1; |
