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/arch/sparc Do the _rtld_relocate_nonplt_se...
details: https://anonhg.NetBSD.org/src/rev/b99cd582b59c
branches: trunk
changeset: 536229:b99cd582b59c
user: mycroft <mycroft%NetBSD.org@localhost>
date: Wed Sep 11 19:11:05 2002 +0000
description:
Do the _rtld_relocate_nonplt_self() thing for SPARC.
diffstat:
libexec/ld.elf_so/arch/sparc/mdreloc.c | 53 +++++++++++++++++++++---------
libexec/ld.elf_so/arch/sparc/rtld_start.S | 18 ++-------
2 files changed, 41 insertions(+), 30 deletions(-)
diffs (123 lines):
diff -r bde3cc299591 -r b99cd582b59c libexec/ld.elf_so/arch/sparc/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc/mdreloc.c Wed Sep 11 18:20:47 2002 +0000
+++ b/libexec/ld.elf_so/arch/sparc/mdreloc.c Wed Sep 11 19:11:05 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdreloc.c,v 1.23 2002/09/09 18:10:21 mycroft Exp $ */
+/* $NetBSD: mdreloc.c,v 1.24 2002/09/11 19:11:05 mycroft Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -160,6 +160,8 @@
};
#define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t])
+void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
+
int
_rtld_relocate_plt_object(obj, rela, addrp, dodebug)
const Obj_Entry *obj;
@@ -233,6 +235,32 @@
obj->pltgot[3] = (Elf_Addr) obj;
}
+void
+_rtld_relocate_nonplt_self(dynp, relocbase)
+ Elf_Dyn *dynp;
+ Elf_Addr relocbase;
+{
+ const Elf_Rela *rela = 0, *relalim;
+ Elf_Addr relasz = 0;
+ Elf_Addr *where;
+
+ for (; dynp->d_tag != DT_NULL; dynp++) {
+ switch (dynp->d_tag) {
+ case DT_RELA:
+ rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
+ break;
+ case DT_RELASZ:
+ relasz = dynp->d_un.d_val;
+ break;
+ }
+ }
+ relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
+ for (; rela < relalim; rela++) {
+ where = (Elf_Addr *)(relocbase + rela->r_offset);
+ *where += (Elf_Addr)(relocbase + rela->r_addend);
+ }
+}
+
int
_rtld_relocate_nonplt_objects(obj, self, dodebug)
const Obj_Entry *obj;
@@ -241,6 +269,9 @@
{
const Elf_Rela *rela;
+ if (self)
+ return (0);
+
for (rela = obj->rela; rela < obj->relalim; rela++) {
Elf_Addr *where;
Elf_Word type, value, mask;
@@ -273,24 +304,12 @@
value = rela->r_addend;
/*
- * Handle relative relocs here, because we might not be able to
- * access the reloc_target_{flags,bitmask}[] tables while
- * relocating ourself.
+ * Handle relative relocs here, as an optimization.
*/
if (type == R_TYPE(RELATIVE)) {
- extern Elf_Addr _GLOBAL_OFFSET_TABLE_[];
- extern Elf_Addr _GOT_END_[];
-
- /* This is the ...iffy hueristic. */
- if (!self ||
- (caddr_t)where < (caddr_t)_GLOBAL_OFFSET_TABLE_ ||
- (caddr_t)where >= (caddr_t)_GOT_END_) {
- *where += (Elf_Addr)(obj->relocbase + value);
- rdbg(dodebug, ("RELATIVE in %s --> %p",
- obj->path, (void *)*where));
- } else
- rdbg(dodebug, ("RELATIVE in %s stays at %p",
- obj->path, (void *)*where));
+ *where += (Elf_Addr)(obj->relocbase + value);
+ rdbg(dodebug, ("RELATIVE in %s --> %p", obj->path,
+ (void *)*where));
continue;
}
diff -r bde3cc299591 -r b99cd582b59c libexec/ld.elf_so/arch/sparc/rtld_start.S
--- a/libexec/ld.elf_so/arch/sparc/rtld_start.S Wed Sep 11 18:20:47 2002 +0000
+++ b/libexec/ld.elf_so/arch/sparc/rtld_start.S Wed Sep 11 19:11:05 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld_start.S,v 1.6 2002/09/09 19:01:52 mycroft Exp $ */
+/* $NetBSD: rtld_start.S,v 1.7 2002/09/11 19:11:05 mycroft Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -56,19 +56,11 @@
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call .LLGETPC0
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
- ld [%l7+_GOT_END_], %o0
+ ld [%l7+_DYNAMIC], %o0
ld [%l7+_GLOBAL_OFFSET_TABLE_], %o1
- mov %l7, %o2
- sub %o2, %o1, %o1
- add %o0, %o1, %o0
- ld [%o2], %o3
-1:
- add %o3, %o1, %o3
- st %o3, [%o2]
- add %o2, 4, %o2
- cmp %o2, %o0
- blu,a 1b
- ld [%o2], %o3
+ sub %l7, %o1, %o1
+ call _rtld_relocate_nonplt_self
+ add %o0, %o1, %o0
call _rtld
add %sp, 64, %o0 /* &argc - 8 */
Home |
Main Index |
Thread Index |
Old Index