diff options
| author | jonathan <jonathan@NetBSD.org> | 1996-11-11 20:33:10 +0000 |
|---|---|---|
| committer | jonathan <jonathan@NetBSD.org> | 1996-11-11 20:33:10 +0000 |
| commit | bbcd2bb1efe5b2bbbaa3f36d78d5c584bd090041 (patch) | |
| tree | 610d71844542d1be6715d9d7b7a8f451ff8ddb5b | |
| parent | 502d34d915150a02b06610f2e6cd73a5ba85896a (diff) | |
Elf32 fixes for mips shared libraries:
* handle interpreters with nonzero virtual address of entry-point:
subtract p_vaddr from computed entrypoint, as the mips elf exec did.
* Add #ifdef ELF_INTERP_NON_RELOCATABLE/#endif around the code
that tries to choose a `good' address at which to load an interpreter,
if none was set by the emul probe function.
(the address chosen could be improved to avoid fragmenting the
process virtual address space).
* define ELF_INTERP_NON_RELOCATABLE in machine/elf_machdep.h for mips CPUs,
which currently use a GNU-derived ld.so.
ELF_INTERP_NON_RELOCATABLE is not necessary for native NetBSD/alpha ELF
binaries. It may be required for GNU-derived ELF dynamic loaders (Linux/i386?)
| -rw-r--r-- | sys/arch/mips/include/elf_machdep.h | 9 | ||||
| -rw-r--r-- | sys/kern/exec_elf32.c | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sys/arch/mips/include/elf_machdep.h b/sys/arch/mips/include/elf_machdep.h index d93b48b6c93..b05140c49b2 100644 --- a/sys/arch/mips/include/elf_machdep.h +++ b/sys/arch/mips/include/elf_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: elf_machdep.h,v 1.1 1996/09/26 21:50:59 cgd Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.2 1996/11/11 20:33:12 jonathan Exp $ */ #define ELF32_MACHDEP_ID_CASES \ case Elf_em_mips: \ @@ -6,3 +6,10 @@ #define ELF64_MACHDEP_ID_CASES \ /* no 64-bit ELF machine types supported */ +/* + * Tell the kernel ELF exec code not to try relocating the interpreter + * (ld.so) for dynamically-linked ELF binaries + */ +#ifdef _KERNEL +#define ELF_INTERP_NON_RELOCATABLE +#endif diff --git a/sys/kern/exec_elf32.c b/sys/kern/exec_elf32.c index af12e56fd51..4b2bd8cbc1c 100644 --- a/sys/kern/exec_elf32.c +++ b/sys/kern/exec_elf32.c @@ -1,4 +1,4 @@ -/* $NetBSD: exec_elf32.c,v 1.19 1996/10/13 22:54:52 cgd Exp $ */ +/* $NetBSD: exec_elf32.c,v 1.20 1996/11/11 20:33:10 jonathan Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou @@ -413,7 +413,7 @@ ELFNAME(load_file)(p, epp, path, vcset, entry, ap, last) /* If entry is within this section it must be text */ if (eh.e_entry >= ph[i].p_vaddr && eh.e_entry < (ph[i].p_vaddr + size)) { - *entry = addr + eh.e_entry; + *entry = addr + eh.e_entry - ph[i].p_vaddr; ap->arg_interp = addr; } addr += size; @@ -612,6 +612,8 @@ ELFNAME2(exec,makecmds)(p, epp) } } + /* this breaks on, e.g., OpenBSD-compatible mips shared binaries. */ +#ifndef ELF_INTERP_NON_RELOCATABLE /* * If no position to load the interpreter was set by a probe * function, pick the same address that a non-fixed mmap(0, ..) @@ -620,6 +622,7 @@ ELFNAME2(exec,makecmds)(p, epp) if (pos == ELFDEFNNAME(NO_ADDR) && epp->ep_emul == &ELFNAMEEND(emul_netbsd)) pos = round_page(epp->ep_daddr + MAXDSIZ); +#endif /* !ELF_INTERP_NON_RELOCATABLE */ /* * Check if we found a dynamically linked binary and arrange to load |
