Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/kern Pull up following revision(s) (requested by simo...



details:   https://anonhg.NetBSD.org/src/rev/0969435b80f5
branches:  netbsd-3
changeset: 577329:0969435b80f5
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Oct 08 08:44:30 2005 +0000

description:
Pull up following revision(s) (requested by simonb in ticket #872):
        sys/kern/exec_elf32.c: revision 1.107
Add a hack to deal with MIPS relocatable shared-linker problem on
COMPAT_16 and earlier that results in a current shared linker running at
address 0 (and thus allows NULL pointer derefs to work).
As noted by Matthias Drochner, this "fix" just checks the first psection
and not the first loadable psection.  This isn't a problem with the
binutils up to now, but might be in the future.

diffstat:

 sys/kern/exec_elf32.c |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 9a381ce305a4 -r 0969435b80f5 sys/kern/exec_elf32.c
--- a/sys/kern/exec_elf32.c     Fri Oct 07 12:04:02 2005 +0000
+++ b/sys/kern/exec_elf32.c     Sat Oct 08 08:44:30 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_elf32.c,v 1.102.2.1 2005/09/18 20:09:50 tron Exp $        */
+/*     $NetBSD: exec_elf32.c,v 1.102.2.2 2005/10/08 08:44:30 tron Exp $        */
 
 /*-
  * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf32.c,v 1.102.2.1 2005/09/18 20:09:50 tron Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf32.c,v 1.102.2.2 2005/10/08 08:44:30 tron Exp $");
 
 /* If not included by exec_elf64.c, ELFSIZE won't be defined. */
 #ifndef ELFSIZE
@@ -398,6 +398,18 @@
        if ((error = exec_read_from(p, vp, eh.e_phoff, ph, phsize)) != 0)
                goto bad;
 
+#ifdef ELF_INTERP_NON_RELOCATABLE
+       /*
+        * Evil hack:  Only MIPS should be non-relocatable, and the
+        * psections should have a high address (typically 0x5ffe0000).
+        * If it's now relocatable, it should be linked at 0 and the
+        * psections should have zeros in the upper part of the address.
+        * Otherwise, force the load at the linked address.
+        */
+       if (*last == ELF_LINK_ADDR && (ph->p_vaddr & 0xffff0000) == 0)
+               *last = ELFDEFNNAME(NO_ADDR);
+#endif
+
        /*
         * If no position to load the interpreter was set by a probe
         * function, pick the same address that a non-fixed mmap(0, ..)



Home | Main Index | Thread Index | Old Index