summaryrefslogtreecommitdiff
path: root/sys/kern/exec_elf32.c
diff options
context:
space:
mode:
authorjonathan <jonathan@NetBSD.org>1996-11-11 20:33:10 +0000
committerjonathan <jonathan@NetBSD.org>1996-11-11 20:33:10 +0000
commitbbcd2bb1efe5b2bbbaa3f36d78d5c584bd090041 (patch)
tree610d71844542d1be6715d9d7b7a8f451ff8ddb5b /sys/kern/exec_elf32.c
parent502d34d915150a02b06610f2e6cd73a5ba85896a (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?)
Diffstat (limited to 'sys/kern/exec_elf32.c')
-rw-r--r--sys/kern/exec_elf32.c7
1 files changed, 5 insertions, 2 deletions
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