Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.4.6 /fs/binfmt_elf.c

Filename:/fs/binfmt_elf.c
Lines Added:6
Lines Deleted:7
Also changed in: (Previous) 2.4.6-pre9  2.4.5-ac24  2.4.5-ac23  2.4.5-ac22  2.4.5-ac20  2.4.5-ac21 
(Following) 2.4.6-ac1  2.4.6-ac2  2.4.6-ac3  2.4.6-ac4  2.4.6-ac5  2.4.7-pre7 

Location
[  2.4.6
  [  fs
     o  binfmt_elf.c

Patch

diff -u --recursive --new-file v2.4.5/linux/fs/binfmt_elf.c linux/fs/binfmt_elf.c
--- v2.4.5/linux/fs/binfmt_elf.c   Sat May 19 18:09:15 2001
+++ linux/fs/binfmt_elf.c   Mon Jul  2 14:38:38 2001
@@ -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);


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.