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.
This commit is contained in:
simonb 2005-10-07 08:33:10 +00:00
parent 9644b9239b
commit 4beb6d8640
1 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf32.c,v 1.106 2005/07/17 23:53:57 junyoung Exp $ */
/* $NetBSD: exec_elf32.c,v 1.107 2005/10/07 08:33:10 simonb 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.106 2005/07/17 23:53:57 junyoung Exp $");
__KERNEL_RCSID(1, "$NetBSD: exec_elf32.c,v 1.107 2005/10/07 08:33:10 simonb Exp $");
/* If not included by exec_elf64.c, ELFSIZE won't be defined. */
#ifndef ELFSIZE
@ -405,6 +405,18 @@ elf_load_file(struct proc *p, struct exec_package *epp, char *path,
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, ..)