diff options
| author | Anton Altaparmakov <aia21@cantab.net> | 2006-01-19 11:39:33 -0500 |
|---|---|---|
| committer | Anton Altaparmakov <aia21@cantab.net> | 2006-01-19 11:39:33 -0500 |
| commit | 944d79559d154c12becde0dab327016cf438f46c (patch) | |
| tree | 50c101806f4d3b6585222dda060559eb4f3e005a /fs/binfmt_elf.c | |
| parent | d087e4bdd24ebe3ae3d0b265b6573ec901af4b4b (diff) | |
| parent | 0f36b018b2e314d45af86449f1a97facb1fbe300 (diff) | |
Merge branch 'master' of /usr/src/ntfs-2.6/
Diffstat (limited to 'fs/binfmt_elf.c')
| -rw-r--r-- | fs/binfmt_elf.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index f36f2210204f..1b117a441298 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 |
| @@ -1212,7 +1218,7 @@ static int writenote(struct memelfnote *men, struct file *file) | |||
| 1212 | if (!dump_seek(file, (off))) \ | 1218 | if (!dump_seek(file, (off))) \ |
| 1213 | goto end_coredump; | 1219 | goto end_coredump; |
| 1214 | 1220 | ||
| 1215 | static inline void fill_elf_header(struct elfhdr *elf, int segs) | 1221 | static void fill_elf_header(struct elfhdr *elf, int segs) |
| 1216 | { | 1222 | { |
| 1217 | memcpy(elf->e_ident, ELFMAG, SELFMAG); | 1223 | memcpy(elf->e_ident, ELFMAG, SELFMAG); |
| 1218 | elf->e_ident[EI_CLASS] = ELF_CLASS; | 1224 | elf->e_ident[EI_CLASS] = ELF_CLASS; |
| @@ -1237,7 +1243,7 @@ static inline void fill_elf_header(struct elfhdr *elf, int segs) | |||
| 1237 | return; | 1243 | return; |
| 1238 | } | 1244 | } |
| 1239 | 1245 | ||
| 1240 | static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset) | 1246 | static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, off_t offset) |
| 1241 | { | 1247 | { |
| 1242 | phdr->p_type = PT_NOTE; | 1248 | phdr->p_type = PT_NOTE; |
| 1243 | phdr->p_offset = offset; | 1249 | phdr->p_offset = offset; |
| @@ -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)); |
