diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
commit | 94bc2be31a01a3055ec94176e595dfe208e92d3b (patch) | |
tree | ebfbe81c6718a6390bfa1b99c6d228237d818576 /fs/binfmt_elf.c | |
parent | c32a0b689cb9cc160cfcd19735bbf50bb70c6ef4 (diff) | |
parent | 58cba4650a7a414eabd2b40cc9d8e45fcdf192d9 (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index f36f2210204f..f979ebbce49c 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -58,7 +58,7 @@ extern int dump_fpu (struct pt_regs *, elf_fpregset_t *); | |||
58 | * If we don't support core dumping, then supply a NULL so we | 58 | * If we don't support core dumping, then supply a NULL so we |
59 | * don't even try. | 59 | * don't even try. |
60 | */ | 60 | */ |
61 | #ifdef USE_ELF_CORE_DUMP | 61 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) |
62 | static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file); | 62 | static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file); |
63 | #else | 63 | #else |
64 | #define elf_core_dump NULL | 64 | #define elf_core_dump NULL |
@@ -288,11 +288,17 @@ static unsigned long elf_map(struct file *filep, unsigned long addr, | |||
288 | struct elf_phdr *eppnt, int prot, int type) | 288 | struct elf_phdr *eppnt, int prot, int type) |
289 | { | 289 | { |
290 | unsigned long map_addr; | 290 | unsigned long map_addr; |
291 | unsigned long pageoffset = ELF_PAGEOFFSET(eppnt->p_vaddr); | ||
291 | 292 | ||
292 | down_write(¤t->mm->mmap_sem); | 293 | down_write(¤t->mm->mmap_sem); |
293 | map_addr = do_mmap(filep, ELF_PAGESTART(addr), | 294 | /* mmap() will return -EINVAL if given a zero size, but a |
294 | eppnt->p_filesz + ELF_PAGEOFFSET(eppnt->p_vaddr), prot, type, | 295 | * segment with zero filesize is perfectly valid */ |
295 | eppnt->p_offset - ELF_PAGEOFFSET(eppnt->p_vaddr)); | 296 | if (eppnt->p_filesz + pageoffset) |
297 | map_addr = do_mmap(filep, ELF_PAGESTART(addr), | ||
298 | eppnt->p_filesz + pageoffset, prot, type, | ||
299 | eppnt->p_offset - pageoffset); | ||
300 | else | ||
301 | map_addr = ELF_PAGESTART(addr); | ||
296 | up_write(¤t->mm->mmap_sem); | 302 | up_write(¤t->mm->mmap_sem); |
297 | return(map_addr); | 303 | return(map_addr); |
298 | } | 304 | } |
@@ -616,7 +622,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
616 | goto out_free_file; | 622 | goto out_free_file; |
617 | 623 | ||
618 | retval = -ENOMEM; | 624 | retval = -ENOMEM; |
619 | elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz, | 625 | elf_interpreter = kmalloc(elf_ppnt->p_filesz, |
620 | GFP_KERNEL); | 626 | GFP_KERNEL); |
621 | if (!elf_interpreter) | 627 | if (!elf_interpreter) |
622 | goto out_free_file; | 628 | goto out_free_file; |
@@ -1107,7 +1113,7 @@ out: | |||
1107 | * Note that some platforms still use traditional core dumps and not | 1113 | * Note that some platforms still use traditional core dumps and not |
1108 | * the ELF core dump. Each platform can select it as appropriate. | 1114 | * the ELF core dump. Each platform can select it as appropriate. |
1109 | */ | 1115 | */ |
1110 | #ifdef USE_ELF_CORE_DUMP | 1116 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) |
1111 | 1117 | ||
1112 | /* | 1118 | /* |
1113 | * ELF core dumper | 1119 | * ELF core dumper |
@@ -1628,17 +1634,17 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file) | |||
1628 | ELF_CORE_WRITE_EXTRA_DATA; | 1634 | ELF_CORE_WRITE_EXTRA_DATA; |
1629 | #endif | 1635 | #endif |
1630 | 1636 | ||
1631 | if ((off_t) file->f_pos != offset) { | 1637 | if ((off_t)file->f_pos != offset) { |
1632 | /* Sanity check */ | 1638 | /* Sanity check */ |
1633 | printk("elf_core_dump: file->f_pos (%ld) != offset (%ld)\n", | 1639 | printk(KERN_WARNING "elf_core_dump: file->f_pos (%ld) != offset (%ld)\n", |
1634 | (off_t) file->f_pos, offset); | 1640 | (off_t)file->f_pos, offset); |
1635 | } | 1641 | } |
1636 | 1642 | ||
1637 | end_coredump: | 1643 | end_coredump: |
1638 | set_fs(fs); | 1644 | set_fs(fs); |
1639 | 1645 | ||
1640 | cleanup: | 1646 | cleanup: |
1641 | while(!list_empty(&thread_list)) { | 1647 | while (!list_empty(&thread_list)) { |
1642 | struct list_head *tmp = thread_list.next; | 1648 | struct list_head *tmp = thread_list.next; |
1643 | list_del(tmp); | 1649 | list_del(tmp); |
1644 | kfree(list_entry(tmp, struct elf_thread_status, list)); | 1650 | kfree(list_entry(tmp, struct elf_thread_status, list)); |