From b2c1aff3d8b045cbe0d73bc208c4bbafa11dd8d3 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Thu, 14 Oct 2010 16:33:50 +0000 Subject: [PATCH] Fix reloc calcurations (mechanically pulled from working i386 and sh3). Now options MODULAR works at least on news68k: # uname -mrs NetBSD 5.99.39 news68k # modstat|grep filesys coredump misc filesys 2 2790 - exec_aout misc filesys 0 1866 coredump exec_elf32 misc filesys 0 6072 coredump exec_script misc filesys 0 972 - kernfs vfs filesys 0 9734 - mfs vfs filesys 0 3656 ffs procfs vfs filesys 0 23924 - # --- sys/arch/m68k/m68k/kobj_machdep.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/arch/m68k/m68k/kobj_machdep.c b/sys/arch/m68k/m68k/kobj_machdep.c index d0e5728e093a..c3c17af1ccbc 100644 --- a/sys/arch/m68k/m68k/kobj_machdep.c +++ b/sys/arch/m68k/m68k/kobj_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: kobj_machdep.c,v 1.2 2008/04/28 20:23:27 martin Exp $ */ +/* $NetBSD: kobj_machdep.c,v 1.3 2010/10/14 16:33:50 tsutsui Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.2 2008/04/28 20:23:27 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.3 2010/10/14 16:33:50 tsutsui Exp $"); #define ELFSIZE ARCH_ELFSIZE @@ -64,8 +64,7 @@ kobj_reloc(kobj_t ko, uintptr_t relocbase, const void *data, addr = kobj_sym_lookup(ko, symnum); if (addr == 0) return -1; - tmp = (Elf_Addr)(relocbase + addr + - rela->r_addend) - (Elf_Addr)where; + tmp = (Elf_Addr)(addr + rela->r_addend) - (Elf_Addr)where; if (*where != tmp) *where = tmp; break; @@ -75,14 +74,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbase, const void *data, addr = kobj_sym_lookup(ko, symnum); if (addr == 0) return -1; - tmp = (Elf_Addr)(relocbase + addr + - rela->r_addend); - if (*where != tmp) - *where = tmp; + tmp = (Elf_Addr)(addr + *where + rela->r_addend); + *where = tmp; break; case R_TYPE(RELATIVE): - *where += (Elf_Addr)relocbase; + *where += (Elf_Addr)(relocbase + rela->r_addend); break; default: