Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so A few things:
details: https://anonhg.NetBSD.org/src/rev/416251d99cfe
branches: trunk
changeset: 536059:416251d99cfe
user: mycroft <mycroft%NetBSD.org@localhost>
date: Thu Sep 05 21:21:06 2002 +0000
description:
A few things:
* Pass a symbol number to _rtld_find_symdef(), not a r_info.
* Don't try to do a symbol lookup when we find an unsupported relocation;
instead get the symbol name from the referencing object's strtab.
* Add preliminary support for `-z combreloc'-style startup optimization on
i386, `#ifdef COMBRELOC'.
diffstat:
libexec/ld.elf_so/arch/alpha/alpha_reloc.c | 17 +++----
libexec/ld.elf_so/arch/arm/mdreloc.c | 18 +++-----
libexec/ld.elf_so/arch/hppa/hppa_reloc.c | 28 ++++++------
libexec/ld.elf_so/arch/i386/mdreloc.c | 61 ++++++++++++++++++++---------
libexec/ld.elf_so/arch/m68k/mdreloc.c | 15 ++----
libexec/ld.elf_so/arch/mips/mips_reloc.c | 23 +++++-----
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c | 17 +++----
libexec/ld.elf_so/arch/sh3/mdreloc.c | 21 +++------
libexec/ld.elf_so/arch/sparc/mdreloc.c | 9 ++-
libexec/ld.elf_so/arch/sparc64/mdreloc.c | 9 ++-
libexec/ld.elf_so/arch/vax/mdreloc.c | 12 ++---
libexec/ld.elf_so/arch/x86_64/mdreloc.c | 26 +++++-------
libexec/ld.elf_so/reloc.c | 5 +-
libexec/ld.elf_so/rtld.h | 4 +-
libexec/ld.elf_so/symbol.c | 7 +-
15 files changed, 137 insertions(+), 135 deletions(-)
diffs (truncated from 842 to 300 lines):
diff -r 485bbcbd92d9 -r 416251d99cfe libexec/ld.elf_so/arch/alpha/alpha_reloc.c
--- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c Thu Sep 05 20:12:43 2002 +0000
+++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c Thu Sep 05 21:21:06 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha_reloc.c,v 1.7 2002/09/05 20:12:43 mycroft Exp $ */
+/* $NetBSD: alpha_reloc.c,v 1.8 2002/09/05 21:21:08 mycroft Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -120,16 +120,17 @@
const Elf_Sym *def;
const Obj_Entry *defobj;
Elf_Addr tmp;
+ unsigned long symnum;
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+ symnum = ELF_R_SYM(rela->r_info);
switch (ELF_R_TYPE(rela->r_info)) {
case R_TYPE(NONE):
break;
case R_TYPE(REFQUAD):
- def = _rtld_find_symdef(rela->r_info, obj, &defobj,
- false);
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
@@ -143,8 +144,7 @@
break;
case R_TYPE(GLOB_DAT):
- def = _rtld_find_symdef(rela->r_info, obj, &defobj,
- false);
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
@@ -192,15 +192,12 @@
break;
default:
- def = _rtld_find_symdef(rela->r_info, obj, &defobj,
- true);
rdbg(dodebug, ("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
- (u_long)ELF_R_SYM(rela->r_info),
- (u_long)ELF_R_TYPE(rela->r_info),
+ symnum, (u_long)ELF_R_TYPE(rela->r_info),
(void *)rela->r_offset, (void *)rela->r_addend,
(void *)*where,
- def ? defobj->strtab + def->st_name : "??"));
+ obj->strtab + obj->symtab[symnum].st_name));
_rtld_error("%s: Unsupported relocation type %ld "
"in non-PLT relocations\n",
obj->path, (u_long) ELF_R_TYPE(rela->r_info));
diff -r 485bbcbd92d9 -r 416251d99cfe libexec/ld.elf_so/arch/arm/mdreloc.c
--- a/libexec/ld.elf_so/arch/arm/mdreloc.c Thu Sep 05 20:12:43 2002 +0000
+++ b/libexec/ld.elf_so/arch/arm/mdreloc.c Thu Sep 05 21:21:06 2002 +0000
@@ -23,8 +23,10 @@
const Elf_Sym *def;
const Obj_Entry *defobj;
Elf_Addr tmp;
+ unsigned long symnum;
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
+ symnum = ELF_R_SYM(rel->r_info);
switch (ELF_R_TYPE(rel->r_info)) {
case R_TYPE(NONE):
@@ -41,8 +43,7 @@
if (addend & 0x00800000)
addend |= 0xff000000;
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- false);
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
tmp = (Elf_Addr)obj->relocbase + def->st_value
@@ -67,8 +68,7 @@
#endif
case R_TYPE(ABS32): /* word32 B + S + A */
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- false);
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
*where += (Elf_Addr)defobj->relocbase + def->st_value;
@@ -78,8 +78,7 @@
break;
case R_TYPE(GLOB_DAT): /* word32 B + S */
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- false);
+ def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
*where = (Elf_Addr)(defobj->relocbase + def->st_value);
@@ -111,14 +110,11 @@
break;
default:
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- true);
rdbg(dodebug, ("sym = %lu, type = %lu, offset = %p, "
"contents = %p, symbol = %s",
- (u_long)ELF_R_SYM(rel->r_info),
- (u_long)ELF_R_TYPE(rel->r_info),
+ symnum, (u_long)ELF_R_TYPE(rel->r_info),
(void *)rel->r_offset, (void *)*where,
- def ? defobj->strtab + def->st_name : "??"));
+ obj->strtab + obj->symtab[symnum].st_name));
_rtld_error("%s: Unsupported relocation type %ld "
"in non-PLT relocations\n",
obj->path, (u_long) ELF_R_TYPE(rel->r_info));
diff -r 485bbcbd92d9 -r 416251d99cfe libexec/ld.elf_so/arch/hppa/hppa_reloc.c
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c Thu Sep 05 20:12:43 2002 +0000
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c Thu Sep 05 21:21:06 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hppa_reloc.c,v 1.5 2002/09/05 20:08:16 mycroft Exp $ */
+/* $NetBSD: hppa_reloc.c,v 1.6 2002/09/05 21:21:09 mycroft Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -292,7 +292,8 @@
* Look up the symbol. While we're relocating self,
* _rtld_objlist is NULL, so just pass in self.
*/
- def = _rtld_find_symdef(rela->r_info, obj, &defobj, false);
+ def = _rtld_find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj,
+ false);
if (def == NULL)
return -1;
func_pc = (Elf_Addr)(defobj->relocbase + def->st_value +
@@ -346,21 +347,23 @@
const Elf_Sym *def;
const Obj_Entry *defobj;
Elf_Addr tmp;
+ unsigned long symnum;
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+ symnum = ELF_R_SYM(rela->r_info);
switch (ELF_R_TYPE(rela->r_info)) {
case R_TYPE(NONE):
break;
case R_TYPE(DIR32):
- if (ELF_R_SYM(rela->r_info)) {
+ if (symnum) {
/*
* This is either a DIR32 against a symbol
* (def->st_name != 0), or against a local
* section (def->st_name == 0).
*/
- def = obj->symtab + ELF_R_SYM(rela->r_info);
+ def = obj->symtab + symnum;
defobj = obj;
if (def->st_name != 0)
/*
@@ -368,8 +371,8 @@
* _rtld_objlist is NULL, so we just
* pass in self.
*/
- def = _rtld_find_symdef(rela->r_info,
- obj, &defobj, false);
+ def = _rtld_find_symdef(symnum, obj,
+ &defobj, false);
if (def == NULL)
return -1;
@@ -403,13 +406,13 @@
break;
case R_TYPE(PLABEL32):
- if (ELF_R_SYM(rela->r_info)) {
+ if (symnum) {
/*
* While we're relocating self, _rtld_objlist
* is NULL, so we just pass in self.
*/
- def = _rtld_find_symdef(rela->r_info, obj,
- &defobj, false);
+ def = _rtld_find_symdef(symnum, obj, &defobj,
+ false);
if (def == NULL)
return -1;
@@ -467,15 +470,12 @@
break;
default:
- def = _rtld_find_symdef(rela->r_info, obj, &defobj,
- true);
rdbg(dodebug, ("sym = %lu, type = %lu, offset = %p, "
"addend = %p, contents = %p, symbol = %s",
- (u_long)ELF_R_SYM(rela->r_info),
- (u_long)ELF_R_TYPE(rela->r_info),
+ symnum, (u_long)ELF_R_TYPE(rela->r_info),
(void *)rela->r_offset, (void *)rela->r_addend,
(void *)*where,
- def ? defobj->strtab + def->st_name : "??"));
+ obj->strtab + obj->symtab[symnum].st_name));
_rtld_error("%s: Unsupported relocation type %ld "
"in non-PLT relocations\n",
obj->path, (u_long) ELF_R_TYPE(rela->r_info));
diff -r 485bbcbd92d9 -r 416251d99cfe libexec/ld.elf_so/arch/i386/mdreloc.c
--- a/libexec/ld.elf_so/arch/i386/mdreloc.c Thu Sep 05 20:12:43 2002 +0000
+++ b/libexec/ld.elf_so/arch/i386/mdreloc.c Thu Sep 05 21:21:06 2002 +0000
@@ -17,14 +17,18 @@
bool dodebug;
{
const Elf_Rel *rel;
+#ifdef COMBRELOC
+ unsigned long lastsym = -1;
+#endif
+ Elf_Addr target;
for (rel = obj->rel; rel < obj->rellim; rel++) {
Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
Elf_Addr tmp;
+ unsigned long symnum;
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
+ symnum = ELF_R_SYM(rel->r_info);
switch (ELF_R_TYPE(rel->r_info)) {
case R_TYPE(NONE):
@@ -32,13 +36,24 @@
#if 1 /* XXX should not occur */
case R_TYPE(PC32):
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- false);
- if (def == NULL)
- return -1;
+#ifdef COMBRELOC
+ if (symnum != lastsym)
+#endif
+ {
+ const Elf_Sym *def;
+ const Obj_Entry *defobj;
+ def = _rtld_find_symdef(symnum, obj, &defobj,
+ false);
+ if (def == NULL)
+ return -1;
+ target = (Elf_Addr)(defobj->relocbase +
+ def->st_value);
+#ifdef COMBRELOC
+ lastsym = symnum;
+#endif
+ }
- *where += (Elf_Addr)(defobj->relocbase + def->st_value) -
- (Elf_Addr)where;
+ *where += target - (Elf_Addr)where;
rdbg(dodebug, ("PC32 %s in %s --> %p in %s",
defobj->strtab + def->st_name, obj->path,
(void *)*where, defobj->path));
@@ -48,13 +63,24 @@
#endif
case R_TYPE(32):
case R_TYPE(GLOB_DAT):
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
- false);
- if (def == NULL)
- return -1;
+#ifdef COMBRELOC
+ if (symnum != lastsym)
+#endif
+ {
+ const Elf_Sym *def;
+ const Obj_Entry *defobj;
+ def = _rtld_find_symdef(symnum, obj, &defobj,
+ false);
+ if (def == NULL)
+ return -1;
+ target = (Elf_Addr)(defobj->relocbase +
+ def->st_value);
+#ifdef COMBRELOC
+ lastsym = symnum;
+#endif
+ }
- tmp = (Elf_Addr)(defobj->relocbase + def->st_value +
- *where);
+ tmp = target + *where;
if (*where != tmp)
*where = tmp;
rdbg(dodebug, ("32/GLOB_DAT %s in %s --> %p in %s",
@@ -85,14 +111,11 @@
break;
default:
- def = _rtld_find_symdef(rel->r_info, obj, &defobj,
Home |
Main Index |
Thread Index |
Old Index