imgact_elf.c (69947) | imgact_elf.c (71497) |
---|---|
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 * | 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 69947 2000-12-13 00:17:05Z jake $ | 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{ | 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 = p->p_ucred; | 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 } | 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); |
|
757 error = elf_corehdr(p, vp, cred, seginfo.count, hdr, hdrsize); 758 759 /* Write the contents of all of the writable segments. */ 760 if (error == 0) { 761 Elf_Phdr *php; 762 off_t offset; 763 int i; 764 --- 4 unchanged lines hidden (view full) --- 769 php->p_filesz, offset, UIO_USERSPACE, 770 IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p); 771 if (error != 0) 772 break; 773 offset += php->p_filesz; 774 php++; 775 } 776 } | 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); |
|
777 free(hdr, M_TEMP); 778 779 return error; 780} 781 782/* 783 * A callback for each_writable_segment() to write out the segment's 784 * program header entry. --- 247 unchanged lines hidden --- | 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 --- |