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 More PPC64 changes.
details: https://anonhg.NetBSD.org/src/rev/fa25d18c04e7
branches: trunk
changeset: 794138:fa25d18c04e7
user: matt <matt%NetBSD.org@localhost>
date: Thu Mar 06 19:19:40 2014 +0000
description:
More PPC64 changes.
Nothing to do for lazy bindings.
Record DT_PPC64_GLINK and make _rtld_bind return it.
When resolving a JMP_SLOT, copy the source function descriptor into the PLTGOT
diffstat:
libexec/ld.elf_so/arch/powerpc/ppc_reloc.c | 44 ++++++++++++++------------
libexec/ld.elf_so/arch/powerpc/rtld_start64.S | 5 +-
libexec/ld.elf_so/headers.c | 10 ++++-
libexec/ld.elf_so/rtld.h | 6 +++-
4 files changed, 39 insertions(+), 26 deletions(-)
diffs (209 lines):
diff -r 923a7b5190ce -r fa25d18c04e7 libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
--- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Thu Mar 06 19:07:13 2014 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Thu Mar 06 19:19:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ppc_reloc.c,v 1.50 2014/03/06 09:34:07 matt Exp $ */
+/* $NetBSD: ppc_reloc.c,v 1.51 2014/03/06 19:19:40 matt Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ppc_reloc.c,v 1.50 2014/03/06 09:34:07 matt Exp $");
+__RCSID("$NetBSD: ppc_reloc.c,v 1.51 2014/03/06 19:19:40 matt Exp $");
#endif /* not lint */
#include <stdarg.h>
@@ -70,8 +70,8 @@
void _rtld_bind_bssplt_start(void);
void _rtld_bind_secureplt_start(void);
#endif
+Elf_Addr _rtld_bind(const Obj_Entry *, Elf_Word);
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
-caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
static int _rtld_relocate_plt_object(const Obj_Entry *,
const Elf_Rela *, int, Elf_Addr *);
@@ -297,9 +297,13 @@
int
_rtld_relocate_plt_lazy(const Obj_Entry *obj)
{
-#ifndef _LP64
+#ifdef _LP64
+ /*
+ * For PowerPC64, the plt stubs handle an empty function descriptor
+ * so there's nothing to do.
+ */
+#else
Elf_Addr * const pltresolve = obj->pltgot + 8;
-#endif
const Elf_Rela *rela;
int reloff;
@@ -310,12 +314,6 @@
assert(ELF_R_TYPE(rela->r_info) == R_TYPE(JMP_SLOT));
-#ifdef _LP64
- /*
- * For now, simply treat then as relative.
- */
- *where += (Elf_Addr)obj->relocbase;
-#else
if (obj->gotptr != NULL) {
/*
* For now, simply treat then as relative.
@@ -345,8 +343,8 @@
*/
/* __syncicache(where - 3, 12); */
}
-#endif
}
+#endif /* !_LP64 */
return 0;
}
@@ -358,7 +356,6 @@
Elf_Addr value;
const Elf_Sym *def;
const Obj_Entry *defobj;
- int distance;
unsigned long info = rela->r_info;
assert(ELF_R_TYPE(info) == R_TYPE(JMP_SLOT));
@@ -370,19 +367,22 @@
return 0;
value = (Elf_Addr)(defobj->relocbase + def->st_value);
- distance = value - (Elf_Addr)where;
rdbg(("bind now/fixup in %s --> new=%p",
defobj->strtab + def->st_name, (void *)value));
#ifdef _LP64
/*
- * For PowerPC64 we simply replace the entry in the PLTGOT with the
- * address of the routine.
+ * For PowerPC64 we simply replace the function descriptor in the
+ * PLTGOT with the one from source object.
*/
assert(where >= (Elf_Word *)obj->pltgot);
assert(where < (Elf_Word *)obj->pltgot + (obj->pltrelalim - obj->pltrela));
- *where = value;
+ const Elf_Addr * const fdesc = (Elf_Addr *) value;
+ where[0] = fdesc[0];
+ where[1] = fdesc[1];
+ where[2] = fdesc[2];
#else
+ ptrdiff_t distance = value - (Elf_Addr)where;
if (obj->gotptr != NULL) {
/*
* For Secure-PLT we simply replace the entry in GOT with the
@@ -391,7 +391,7 @@
assert(where >= (Elf_Word *)obj->pltgot);
assert(where < (Elf_Word *)obj->pltgot + (obj->pltrelalim - obj->pltrela));
*where = value;
- } else if (abs(distance) < 32*1024*1024) { /* inside 32MB? */
+ } else if (labs(distance) < 32*1024*1024) { /* inside 32MB? */
/* b value # branch directly */
*where = 0x48000000 | (distance & 0x03fffffc);
__syncicache(where, 4);
@@ -440,7 +440,7 @@
return 0;
}
-caddr_t
+Elf_Addr
_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
{
const Elf_Rela *rela = obj->pltrela + reloff;
@@ -455,7 +455,11 @@
_rtld_die();
_rtld_shared_exit();
- return (caddr_t)new_value;
+#ifdef _LP64
+ return obj->glink;
+#else
+ return new_value;
+#endif
}
int
diff -r 923a7b5190ce -r fa25d18c04e7 libexec/ld.elf_so/arch/powerpc/rtld_start64.S
--- a/libexec/ld.elf_so/arch/powerpc/rtld_start64.S Thu Mar 06 19:07:13 2014 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/rtld_start64.S Thu Mar 06 19:19:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld_start64.S,v 1.1 2014/03/06 07:47:19 matt Exp $ */
+/* $NetBSD: rtld_start64.S,v 1.2 2014/03/06 19:19:40 matt Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
@@ -107,8 +107,7 @@
CALL(_rtld_bind) // _rtld_bind(obj, reloff)
mtctr %r3
- ld %r2,8(%r31) // load TOC for function
- ld %r11,16(%r31) // load env ptr for function.
+ mr %r12,%r31 // restore r12
ld %r0,8(%r1) // get saved CR
mtcr %r0 // restore it
diff -r 923a7b5190ce -r fa25d18c04e7 libexec/ld.elf_so/headers.c
--- a/libexec/ld.elf_so/headers.c Thu Mar 06 19:07:13 2014 +0000
+++ b/libexec/ld.elf_so/headers.c Thu Mar 06 19:19:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: headers.c,v 1.52 2013/08/03 13:17:05 skrll Exp $ */
+/* $NetBSD: headers.c,v 1.53 2014/03/06 19:19:40 matt Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.52 2013/08/03 13:17:05 skrll Exp $");
+__RCSID("$NetBSD: headers.c,v 1.53 2014/03/06 19:19:40 matt Exp $");
#endif /* not lint */
#include <err.h>
@@ -298,10 +298,16 @@
break;
#endif
#ifdef __powerpc__
+#ifdef _LP64
+ case DT_PPC64_GLINK:
+ obj->glink = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
+ break;
+#else
case DT_PPC_GOT:
obj->gotptr = (Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
break;
#endif
+#endif
case DT_FLAGS_1:
obj->z_now =
((dynp->d_un.d_val & DF_1_BIND_NOW) != 0);
diff -r 923a7b5190ce -r fa25d18c04e7 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Thu Mar 06 19:07:13 2014 +0000
+++ b/libexec/ld.elf_so/rtld.h Thu Mar 06 19:19:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.h,v 1.116 2013/05/09 15:38:14 christos Exp $ */
+/* $NetBSD: rtld.h,v 1.117 2014/03/06 19:19:40 matt Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -259,8 +259,12 @@
* object we know about. */
#ifdef __powerpc__
+#ifdef _LP64
+ Elf_Addr glink; /* global linkage */
+#else
Elf_Addr *gotptr; /* GOT table (secure-plt only) */
#endif
+#endif
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
/* Thread Local Storage support for this module */
Home |
Main Index |
Thread Index |
Old Index