patch-2.4.6 linux/fs/binfmt_elf.c
Next file: linux/fs/block_dev.c
Previous file: linux/fs/autofs4/expire.c
Back to the patch index
Back to the overall index
- Lines: 34
- Date:
Mon Jul 2 14:38:38 2001
- Orig file:
v2.4.5/linux/fs/binfmt_elf.c
- Orig date:
Sat May 19 18:09:15 2001
diff -u --recursive --new-file v2.4.5/linux/fs/binfmt_elf.c linux/fs/binfmt_elf.c
@@ -396,7 +396,7 @@
static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
{
struct file *interpreter = NULL; /* to shut gcc up */
- unsigned long load_addr = 0, load_bias;
+ unsigned long load_addr = 0, load_bias = 0;
int load_addr_set = 0;
char * elf_interpreter = NULL;
unsigned int interpreter_type = INTERPRETER_NONE;
@@ -595,12 +595,6 @@
setup_arg_pages(bprm); /* XXX: check error */
current->mm->start_stack = bprm->p;
- /* Try and get dynamic programs out of the way of the default mmap
- base, as well as whatever program they might try to exec. This
- is because the brk will follow the loader, and is not movable. */
-
- load_bias = ELF_PAGESTART(elf_ex.e_type==ET_DYN ? ELF_ET_DYN_BASE : 0);
-
/* Now we do a little grungy work by mmaping the ELF image into
the correct location in memory. At this point, we assume that
the image should be loaded at fixed address, not at a variable
@@ -624,6 +618,11 @@
vaddr = elf_ppnt->p_vaddr;
if (elf_ex.e_type == ET_EXEC || load_addr_set) {
elf_flags |= MAP_FIXED;
+ } else if (elf_ex.e_type == ET_DYN) {
+ /* Try and get dynamic programs out of the way of the default mmap
+ base, as well as whatever program they might try to exec. This
+ is because the brk will follow the loader, and is not movable. */
+ load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
}
error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, elf_prot, elf_flags);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)