Deleted Added
full compact
imgact_elf.c (108696) imgact_elf.c (109623)
1/*-
2 * Copyright (c) 2000 David O'Brien
3 * Copyright (c) 1995-1996 S�ren Schmidt
4 * Copyright (c) 1996 Peter Wemm
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
1/*-
2 * Copyright (c) 2000 David O'Brien
3 * Copyright (c) 1995-1996 S�ren Schmidt
4 * Copyright (c) 1996 Peter Wemm
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sys/kern/imgact_elf.c 108696 2003-01-05 03:48:14Z jake $
30 * $FreeBSD: head/sys/kern/imgact_elf.c 109623 2003-01-21 08:56:16Z alfred $
31 */
32
33#include <sys/param.h>
34#include <sys/exec.h>
35#include <sys/fcntl.h>
36#include <sys/imgact.h>
37#include <sys/imgact_elf.h>
38#include <sys/kernel.h>

--- 472 unchanged lines hidden (view full) ---

511 vm_prot_t prot;
512 u_long rbase;
513 u_long base_addr = 0;
514 int error, i, numsegs;
515
516 if (curthread->td_proc != p)
517 panic("elf_load_file - thread"); /* XXXKSE DIAGNOSTIC */
518
31 */
32
33#include <sys/param.h>
34#include <sys/exec.h>
35#include <sys/fcntl.h>
36#include <sys/imgact.h>
37#include <sys/imgact_elf.h>
38#include <sys/kernel.h>

--- 472 unchanged lines hidden (view full) ---

511 vm_prot_t prot;
512 u_long rbase;
513 u_long base_addr = 0;
514 int error, i, numsegs;
515
516 if (curthread->td_proc != p)
517 panic("elf_load_file - thread"); /* XXXKSE DIAGNOSTIC */
518
519 tempdata = malloc(sizeof(*tempdata), M_TEMP, M_WAITOK);
519 tempdata = malloc(sizeof(*tempdata), M_TEMP, 0);
520 nd = &tempdata->nd;
521 attr = &tempdata->attr;
522 imgp = &tempdata->image_params;
523
524 /*
525 * Initialize part of the common data
526 */
527 imgp->proc = p;

--- 279 unchanged lines hidden (view full) ---

807 vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr;
808
809 addr = ELF_RTLD_ADDR(vmspace);
810
811 imgp->entry_addr = entry;
812
813 imgp->proc->p_sysent = sv;
814 if (interp != NULL) {
520 nd = &tempdata->nd;
521 attr = &tempdata->attr;
522 imgp = &tempdata->image_params;
523
524 /*
525 * Initialize part of the common data
526 */
527 imgp->proc = p;

--- 279 unchanged lines hidden (view full) ---

807 vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr;
808
809 addr = ELF_RTLD_ADDR(vmspace);
810
811 imgp->entry_addr = entry;
812
813 imgp->proc->p_sysent = sv;
814 if (interp != NULL) {
815 path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
815 path = malloc(MAXPATHLEN, M_TEMP, 0);
816 snprintf(path, MAXPATHLEN, "%s%s", brand_info->emul_path,
817 interp);
818 if ((error = __elfN(load_file)(imgp->proc, path, &addr,
819 &imgp->entry_addr, sv->sv_pagesize)) != 0) {
820 if ((error = __elfN(load_file)(imgp->proc, interp,
821 &addr, &imgp->entry_addr, sv->sv_pagesize)) != 0) {
822 uprintf("ELF interpreter %s not found\n",
823 path);
824 free(path, M_TEMP);
825 goto fail;
826 }
827 }
828 free(path, M_TEMP);
829 }
830
831 /*
832 * Construct auxargs table (used by the fixup routine)
833 */
816 snprintf(path, MAXPATHLEN, "%s%s", brand_info->emul_path,
817 interp);
818 if ((error = __elfN(load_file)(imgp->proc, path, &addr,
819 &imgp->entry_addr, sv->sv_pagesize)) != 0) {
820 if ((error = __elfN(load_file)(imgp->proc, interp,
821 &addr, &imgp->entry_addr, sv->sv_pagesize)) != 0) {
822 uprintf("ELF interpreter %s not found\n",
823 path);
824 free(path, M_TEMP);
825 goto fail;
826 }
827 }
828 free(path, M_TEMP);
829 }
830
831 /*
832 * Construct auxargs table (used by the fixup routine)
833 */
834 elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK);
834 elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, 0);
835 elf_auxargs->execfd = -1;
836 elf_auxargs->phdr = proghdr;
837 elf_auxargs->phent = hdr->e_phentsize;
838 elf_auxargs->phnum = hdr->e_phnum;
839 elf_auxargs->pagesz = PAGE_SIZE;
840 elf_auxargs->base = addr;
841 elf_auxargs->flags = 0;
842 elf_auxargs->entry = entry;

--- 103 unchanged lines hidden (view full) ---

946
947 if (hdrsize + seginfo.size >= limit)
948 return (EFAULT);
949
950 /*
951 * Allocate memory for building the header, fill it up,
952 * and write it out.
953 */
835 elf_auxargs->execfd = -1;
836 elf_auxargs->phdr = proghdr;
837 elf_auxargs->phent = hdr->e_phentsize;
838 elf_auxargs->phnum = hdr->e_phnum;
839 elf_auxargs->pagesz = PAGE_SIZE;
840 elf_auxargs->base = addr;
841 elf_auxargs->flags = 0;
842 elf_auxargs->entry = entry;

--- 103 unchanged lines hidden (view full) ---

946
947 if (hdrsize + seginfo.size >= limit)
948 return (EFAULT);
949
950 /*
951 * Allocate memory for building the header, fill it up,
952 * and write it out.
953 */
954 hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
954 hdr = malloc(hdrsize, M_TEMP, 0);
955 if (hdr == NULL) {
956 return (EINVAL);
957 }
958 error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize);
959
960 /* Write the contents of all of the writable segments. */
961 if (error == 0) {
962 Elf_Phdr *php;

--- 145 unchanged lines hidden (view full) ---

1108 prpsinfo_t psinfo;
1109 } *tempdata;
1110 struct proc *p = td->td_proc;
1111 size_t off;
1112 prstatus_t *status;
1113 prfpregset_t *fpregset;
1114 prpsinfo_t *psinfo;
1115
955 if (hdr == NULL) {
956 return (EINVAL);
957 }
958 error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize);
959
960 /* Write the contents of all of the writable segments. */
961 if (error == 0) {
962 Elf_Phdr *php;

--- 145 unchanged lines hidden (view full) ---

1108 prpsinfo_t psinfo;
1109 } *tempdata;
1110 struct proc *p = td->td_proc;
1111 size_t off;
1112 prstatus_t *status;
1113 prfpregset_t *fpregset;
1114 prpsinfo_t *psinfo;
1115
1116 tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO | M_WAITOK);
1116 tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO | 0);
1117 status = &tempdata->status;
1118 fpregset = &tempdata->fpregset;
1119 psinfo = &tempdata->psinfo;
1120
1121 /* Gather the information for the header. */
1122 status->pr_version = PRSTATUS_VERSION;
1123 status->pr_statussz = sizeof(prstatus_t);
1124 status->pr_gregsetsz = sizeof(gregset_t);

--- 138 unchanged lines hidden ---
1117 status = &tempdata->status;
1118 fpregset = &tempdata->fpregset;
1119 psinfo = &tempdata->psinfo;
1120
1121 /* Gather the information for the header. */
1122 status->pr_version = PRSTATUS_VERSION;
1123 status->pr_statussz = sizeof(prstatus_t);
1124 status->pr_gregsetsz = sizeof(gregset_t);

--- 138 unchanged lines hidden ---