patch-2.3.99-pre6 linux/fs/binfmt_elf.c
Next file: linux/fs/block_dev.c
Previous file: linux/fs/binfmt_aout.c
Back to the patch index
Back to the overall index
- Lines: 151
- Date:
Mon Apr 24 17:57:42 2000
- Orig file:
v2.3.99-pre5/linux/fs/binfmt_elf.c
- Orig date:
Mon Mar 27 08:08:29 2000
diff -u --recursive --new-file v2.3.99-pre5/linux/fs/binfmt_elf.c linux/fs/binfmt_elf.c
@@ -479,10 +479,22 @@
#ifdef __sparc__
if (ibcs2_interpreter) {
unsigned long old_pers = current->personality;
-
- current->personality = PER_SVR4;
+ struct exec_domain *old_domain = current->exec_domain;
+ struct exec_domain *new_domain;
+ struct fs_struct *old_fs = current->fs, *new_fs;
+ get_exec_domain(old_domain);
+ atomic_inc(&old_fs->count);
+
+ set_personality(PER_SVR4);
interpreter = open_exec(elf_interpreter);
+
+ new_domain = current->exec_domain;
+ new_fs = current->fs;
current->personality = old_pers;
+ current->exec_domain = old_domain;
+ current->fs = old_fs;
+ put_exec_domain(new_domain);
+ put_fs_struct(new_fs);
} else
#endif
{
@@ -668,19 +680,8 @@
if (interpreter_type != INTERPRETER_AOUT)
sys_close(elf_exec_fileno);
- put_exec_domain(current->exec_domain);
- if (current->binfmt && current->binfmt->module)
- __MOD_DEC_USE_COUNT(current->binfmt->module);
- current->exec_domain = lookup_exec_domain(current->personality);
- current->binfmt = &elf_format;
- if (current->binfmt && current->binfmt->module)
- __MOD_INC_USE_COUNT(current->binfmt->module);
+ set_binfmt(&elf_format);
-#ifndef VM_STACK_FLAGS
- lock_kernel();
- current->executable = dget(bprm->file->f_dentry);
- unlock_kernel();
-#endif
compute_creds(bprm);
current->flags &= ~PF_FORKNOEXEC;
bprm->p = (unsigned long)
@@ -962,7 +963,7 @@
#undef DUMP_SEEK
#define DUMP_WRITE(addr, nr) \
- if (!dump_write(file, (addr), (nr))) \
+ if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
goto end_coredump;
#define DUMP_SEEK(off) \
if (!dump_seek(file, (off))) \
@@ -979,8 +980,8 @@
int has_dumped = 0;
mm_segment_t fs;
int segs;
+ size_t size = 0;
int i;
- size_t size;
struct vm_area_struct *vma;
struct elfhdr elf;
off_t offset = 0, dataoff;
@@ -991,24 +992,10 @@
elf_fpregset_t fpu; /* NT_PRFPREG */
struct elf_prpsinfo psinfo; /* NT_PRPSINFO */
- /* Count what's needed to dump, up to the limit of coredump size */
- segs = 0;
- size = 0;
- for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
- if (maydump(vma))
- {
- unsigned long sz = vma->vm_end-vma->vm_start;
-
- if (size+sz >= limit)
- break;
- else
- size += sz;
- }
+ segs = current->mm->map_count;
- segs++;
- }
#ifdef DEBUG
- printk("elf_core_dump: %d segs taking %d bytes\n", segs, size);
+ printk("elf_core_dump: %d segs %lu limit\n", segs, limit);
#endif
/* Set up header */
@@ -1165,13 +1152,10 @@
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
/* Write program headers for segments dump */
- for(vma = current->mm->mmap, i = 0;
- i < segs && vma != NULL; vma = vma->vm_next) {
+ for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
struct elf_phdr phdr;
size_t sz;
- i++;
-
sz = vma->vm_end - vma->vm_start;
phdr.p_type = PT_LOAD;
@@ -1197,19 +1181,36 @@
DUMP_SEEK(dataoff);
- for(i = 0, vma = current->mm->mmap;
- i < segs && vma != NULL;
- vma = vma->vm_next) {
- unsigned long addr = vma->vm_start;
- unsigned long len = vma->vm_end - vma->vm_start;
+ for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
+ unsigned long addr;
- i++;
if (!maydump(vma))
continue;
#ifdef DEBUG
printk("elf_core_dump: writing %08lx %lx\n", addr, len);
#endif
- DUMP_WRITE((void *)addr, len);
+ for (addr = vma->vm_start;
+ addr < vma->vm_end;
+ addr += PAGE_SIZE) {
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+
+ pgd = pgd_offset(vma->vm_mm, addr);
+ pmd = pmd_alloc(pgd, addr);
+
+ if (!pmd)
+ goto end_coredump;
+ pte = pte_alloc(pmd, addr);
+ if (!pte)
+ goto end_coredump;
+ if (!pte_present(*pte) &&
+ pte_none(*pte)) {
+ DUMP_SEEK (file->f_pos + PAGE_SIZE);
+ } else {
+ DUMP_WRITE((void*)addr, PAGE_SIZE);
+ }
+ }
}
if ((off_t) file->f_pos != offset) {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)