1/*- 2 * Copyright (c) 1995-1996 S�ren Schmidt 3 * Copyright (c) 1996 Peter Wemm 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/kern/imgact_elf.c 71497 2001-01-24 00:27:28Z jhb $ |
30 */ 31 32#include "opt_rlimit.h" 33 34#include <sys/param.h> 35#include <sys/exec.h> 36#include <sys/fcntl.h> 37#include <sys/imgact.h> --- 679 unchanged lines hidden (view full) --- 717extern int osreldate; 718 719int 720elf_coredump(p, vp, limit) 721 register struct proc *p; 722 register struct vnode *vp; 723 off_t limit; 724{ |
725 register struct ucred *cred; |
726 int error = 0; 727 struct sseg_closure seginfo; 728 void *hdr; 729 size_t hdrsize; 730 731 /* Size the program segments. */ 732 seginfo.count = 0; 733 seginfo.size = 0; --- 15 unchanged lines hidden (view full) --- 749 /* 750 * Allocate memory for building the header, fill it up, 751 * and write it out. 752 */ 753 hdr = malloc(hdrsize, M_TEMP, M_WAITOK); 754 if (hdr == NULL) { 755 return EINVAL; 756 } |
757 PROC_LOCK(p); 758 cred = p->p_ucred; 759 crhold(cred); 760 PROC_UNLOCK(p); |
761 error = elf_corehdr(p, vp, cred, seginfo.count, hdr, hdrsize); 762 763 /* Write the contents of all of the writable segments. */ 764 if (error == 0) { 765 Elf_Phdr *php; 766 off_t offset; 767 int i; 768 --- 4 unchanged lines hidden (view full) --- 773 php->p_filesz, offset, UIO_USERSPACE, 774 IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p); 775 if (error != 0) 776 break; 777 offset += php->p_filesz; 778 php++; 779 } 780 } |
781 crfree(cred); |
782 free(hdr, M_TEMP); 783 784 return error; 785} 786 787/* 788 * A callback for each_writable_segment() to write out the segment's 789 * program header entry. --- 247 unchanged lines hidden --- |