Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/powerpc Adapt to new elf_machdep.h
details: https://anonhg.NetBSD.org/src/rev/49e47d0b8f07
branches: trunk
changeset: 794108:49e47d0b8f07
user: matt <matt%NetBSD.org@localhost>
date: Thu Mar 06 09:22:52 2014 +0000
description:
Adapt to new elf_machdep.h
Add limited ELF64 support.
diffstat:
sys/arch/powerpc/powerpc/kobj_machdep.c | 45 +++++++++++++++++++++-----------
1 files changed, 29 insertions(+), 16 deletions(-)
diffs (113 lines):
diff -r 47d1606156bf -r 49e47d0b8f07 sys/arch/powerpc/powerpc/kobj_machdep.c
--- a/sys/arch/powerpc/powerpc/kobj_machdep.c Thu Mar 06 09:03:41 2014 +0000
+++ b/sys/arch/powerpc/powerpc/kobj_machdep.c Thu Mar 06 09:22:52 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kobj_machdep.c,v 1.5 2011/06/08 17:19:20 matt Exp $ */
+/* $NetBSD: kobj_machdep.c,v 1.6 2014/03/06 09:22:52 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.5 2011/06/08 17:19:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.6 2014/03/06 09:22:52 matt Exp $");
#define ELFSIZE ARCH_ELFSIZE
@@ -66,6 +66,9 @@
kobj_reloc(kobj_t ko, uintptr_t relocbase, const void *data,
bool isrela, bool local)
{
+#ifdef _LP64
+ Elf64_Half *wwhere;
+#endif
Elf_Addr *where;
Elf32_Half *hwhere;
Elf_Addr addr;
@@ -80,12 +83,15 @@
rela = (const Elf_Rela *)data;
where = (Elf_Addr *) (relocbase + rela->r_offset);
hwhere = (Elf32_Half *) (relocbase + rela->r_offset);
+#ifdef _LP64
+ wwhere = (Elf64_Half *) (relocbase + rela->r_offset);
+#endif
addend = rela->r_addend;
rtype = ELF_R_TYPE(rela->r_info);
symidx = ELF_R_SYM(rela->r_info);
switch (rtype) {
- case R_PPC_NONE:
+ case R_PPC_NONE:
break;
case R_PPC_RELATIVE: /* word32 B + A */
@@ -100,12 +106,15 @@
addend -= relocbase + rela->r_offset; /* A -= P */
/* FALLTHROUGH */
- case R_PPC_32: /* word32 S + A */
- case R_PPC_16: /* half16* S + A */
- case R_PPC_16_LO: /* half16 #lo(S + A) */
- case R_PPC_16_HA: /* half16 #ha(S + A) */
- case R_PPC_16_HI: /* half16 #hi(S + A) */
- addr = kobj_sym_lookup(ko, symidx);
+#ifdef _LP64
+ case R_PPC_ADDR64: /* doubleword64 S + A */
+#endif
+ case R_PPC_ADDR32: /* word32 S + A */
+ case R_PPC_ADDR16: /* half16* S + A */
+ case R_PPC_ADDR16_LO: /* half16 #lo(S + A) */
+ case R_PPC_ADDR16_HA: /* half16 #ha(S + A) */
+ case R_PPC_ADDR16_HI: /* half16 #hi(S + A) */
+ addr = kobj_sym_lookup(ko, symidx);
if (addr == 0)
return -1;
@@ -123,34 +132,38 @@
break;
default:
- printf("kobj_reloc: unexpected relocation type %u\n", rtype);
+ printf("kobj_reloc: unexpected relocation type %u\n", rtype);
return -1;
}
switch (rtype) {
- case R_PPC_RELATIVE: /* word32 B + A */
case R_PPC_REL32: /* word32 S + A - P */
- case R_PPC_32: /* word32 S + A */
+#ifdef _LP64
+ *wwhere = addend;
+ break;
+#endif
+ case R_PPC_RELATIVE: /* doubleword64/word32 B + A */
+ case R_PPC_ADDR32: /* doubleword64/word32 S + A */
*where = addend;
break;
case R_PPC_REL16: /* half16* (S + A - P) */
- case R_PPC_16: /* half16* S + A */
+ case R_PPC_ADDR16: /* half16* S + A */
if ((int16_t) addend != addend)
return -1;
/* FALLTHROUGH */
case R_PPC_REL16_LO: /* half16 #lo(S + A - P) */
- case R_PPC_16_LO: /* half16 #lo(S + A) */
+ case R_PPC_ADDR16_LO: /* half16 #lo(S + A) */
*hwhere = addend & 0xffff;
break;
case R_PPC_REL16_HA: /* half16 #ha(S + A - P) */
- case R_PPC_16_HA: /* half16 #ha(S + A) */
+ case R_PPC_ADDR16_HA: /* half16 #ha(S + A) */
addend += 0x8000;
/* FALLTHROUGH */
case R_PPC_REL16_HI: /* half16 #hi(S + A - P) */
- case R_PPC_16_HI: /* half16 #hi(S + A) */
+ case R_PPC_ADDR16_HI: /* half16 #hi(S + A) */
*hwhere = (addend >> 16) & 0xffff;
break;
}
Home |
Main Index |
Thread Index |
Old Index