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/powerpc Implement _rtld_relocate_nonp...
details: https://anonhg.NetBSD.org/src/rev/65b5ed6fb3f8
branches: trunk
changeset: 536238:65b5ed6fb3f8
user: mycroft <mycroft%NetBSD.org@localhost>
date: Wed Sep 11 21:14:08 2002 +0000
description:
Implement _rtld_relocate_nonplt_self() here.
diffstat:
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c | 37 +++++++++++++++++++++++++---
libexec/ld.elf_so/arch/powerpc/rtld_start.S | 17 +++---------
2 files changed, 38 insertions(+), 16 deletions(-)
diffs (103 lines):
diff -r a747e9647567 -r 65b5ed6fb3f8 libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
--- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Wed Sep 11 20:56:09 2002 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Wed Sep 11 21:14:08 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ppc_reloc.c,v 1.21 2002/09/06 15:17:57 mycroft Exp $ */
+/* $NetBSD: ppc_reloc.c,v 1.22 2002/09/11 21:14:08 mycroft Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
@@ -46,6 +46,8 @@
((u_int32_t)(x) + 0x10000) : (u_int32_t)(x)) >> 16)
#define l(x) ((u_int32_t)(x) & 0xffff)
+void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
+
/*
* Bind a pltgot slot indexed by reloff.
*/
@@ -156,6 +158,32 @@
__syncicache(pltcall, 72 + N * 8);
}
+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;
@@ -164,6 +192,9 @@
{
const Elf_Rela *rela;
+ if (self)
+ return 0;
+
for (rela = obj->rela; rela < obj->relalim; rela++) {
Elf_Addr *where;
const Elf_Sym *def;
@@ -194,9 +225,7 @@
break;
case R_TYPE(RELATIVE): /* word32 B + A */
- tmp = (Elf_Addr)(obj->relocbase + rela->r_addend);
- if (*where != tmp)
- *where = tmp;
+ *where = (Elf_Addr)(obj->relocbase + rela->r_addend);
rdbg(dodebug, ("RELATIVE in %s --> %p", obj->path,
(void *)*where));
break;
diff -r a747e9647567 -r 65b5ed6fb3f8 libexec/ld.elf_so/arch/powerpc/rtld_start.S
--- a/libexec/ld.elf_so/arch/powerpc/rtld_start.S Wed Sep 11 20:56:09 2002 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/rtld_start.S Wed Sep 11 21:14:08 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld_start.S,v 1.6 2002/09/10 02:52:33 mycroft Exp $ */
+/* $NetBSD: rtld_start.S,v 1.7 2002/09/11 21:14:08 mycroft Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
@@ -47,17 +47,10 @@
mflr 11 # r11 = (real) GOT
lwz 10,_GLOBAL_OFFSET_TABLE_@got(11)
# the linker thought GOT were ...
- subf 9,10,11 # r9 = displacement
-
- lwz 8,_GOT_END_@got(11)
- add 8,8,9 # add the displacement
-
-1: lwz 3,0(11)
- add 3,3,9 # add the displacement
- stw 3,0(11)
- addi 11,11,4 # r11++
- cmplw 0,11,8 # done?
- blt 1b
+ lwz 3,_DYNAMIC@got(11)
+ subf 4,10,11 # r4 = relocbase
+ add 3,3,4 # r3 = &_DYNAMIC
+ bl _rtld_relocate_nonplt_self@plt
lwz 4,16(1)
addi 3,4,-12 # sp = &argv[-3] /* XXX */
Home |
Main Index |
Thread Index |
Old Index