diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index f36f2210204f..80ca932ba0bd 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 | } |
@@ -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 |