Lines Matching +full:protect +full:- +full:exec

53 #include <sys/exec.h>
99 /* Link against the non-compat instances when compiling the 32-bit version. */
117 ASSERT(phdrp->p_type == PT_SUNWDTRACE); in dtrace_safe_phdr()
123 if (phdrp->p_memsz < PT_SUNWDTRACE_SIZE || in dtrace_safe_phdr()
124 (phdrp->p_flags & (PF_R | PF_W | PF_X)) != (PF_R | PF_W | PF_X)) in dtrace_safe_phdr()
125 return (-1); in dtrace_safe_phdr()
127 args->thrptr = phdrp->p_vaddr + base; in dtrace_safe_phdr()
146 if (secflag_isset(p->p_secflags.psf_lower, flag)) in handle_secflag_dt()
149 secflag_isset(p->p_secflags.psf_inherit, flag)) in handle_secflag_dt()
152 secflag_clear(&p->p_secflags.psf_effective, flag); in handle_secflag_dt()
154 if (!secflag_isset(p->p_secflags.psf_upper, flag)) in handle_secflag_dt()
158 !secflag_isset(p->p_secflags.psf_inherit, flag)) in handle_secflag_dt()
161 secflag_set(&p->p_secflags.psf_effective, flag); in handle_secflag_dt()
173 if (target > ctx->ecc_bufsz) { in elf_ctx_resize_scratch()
174 if (ctx->ecc_buf != NULL) { in elf_ctx_resize_scratch()
175 kmem_free(ctx->ecc_buf, ctx->ecc_bufsz); in elf_ctx_resize_scratch()
177 ctx->ecc_buf = kmem_alloc(target, KM_SLEEP); in elf_ctx_resize_scratch()
178 ctx->ecc_bufsz = target; in elf_ctx_resize_scratch()
207 uprintf("%s: Cannot execute %s\n", exec_file, args->pathname); in mapexec_brand()
215 uprintf("%s: Cannot read %s\n", exec_file, args->pathname); in mapexec_brand()
220 uprintf("%s: Nothing to load in %s", exec_file, args->pathname); in mapexec_brand()
230 uprintf("%s: Cannot map %s\n", exec_file, args->pathname); in mapexec_brand()
231 if (uphdr != NULL && uphdr->p_flags == 0) in mapexec_brand()
247 if (ehdr->e_type == ET_EXEC && *interp == 0) in mapexec_brand()
251 *uphdr_vaddr = uphdr->p_vaddr; in mapexec_brand()
253 if (uphdr->p_flags == 0) in mapexec_brand()
256 *uphdr_vaddr = (Addr)-1; in mapexec_brand()
276 int fd = -1; in elfexec()
316 ASSERT(p->p_model == DATAMODEL_ILP32 || p->p_model == DATAMODEL_LP64); in elfexec()
319 ehdrp = &bigwad->ehdr; in elfexec()
320 dlnp = bigwad->dl_name; in elfexec()
321 pathbufp = bigwad->pathbuf; in elfexec()
335 if (ehdrp->e_entry == 0) { in elfexec()
341 * Put data model that we're exec-ing to into the args passed to in elfexec()
343 * Now that we know whether we are exec-ing a 32-bit or 64-bit in elfexec()
347 if (ehdrp->e_ident[EI_CLASS] == ELFCLASS32) { in elfexec()
348 args->to_model = DATAMODEL_ILP32; in elfexec()
349 *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS32-1); in elfexec()
351 args->to_model = DATAMODEL_LP64; in elfexec()
352 args->stk_prot &= ~PROT_EXEC; in elfexec()
354 args->dat_prot &= ~PROT_EXEC; in elfexec()
356 *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS64-1); in elfexec()
359 args->to_model = DATAMODEL_ILP32; in elfexec()
360 *execsz = btopr(SINCR) + btopr(SSIZE) + btopr(NCARGS-1); in elfexec()
365 * what kind of elf binary we're trying to run, 32-bit or 64-bit. in elfexec()
367 * args->to_model to see if the target is 32-bit or 64-bit without in elfexec()
378 error = BROP(p)->b_elfexec(vp, uap, args, in elfexec()
387 * determine any non-default stack protections, in elfexec()
390 const uint_t hsize = ehdrp->e_phentsize; in elfexec()
392 for (i = nphdrs; i > 0; i--) { in elfexec()
393 switch (phdrp->p_type) { in elfexec()
401 args->stk_prot = PROT_USER; in elfexec()
402 if (phdrp->p_flags & PF_R) in elfexec()
403 args->stk_prot |= PROT_READ; in elfexec()
404 if (phdrp->p_flags & PF_W) in elfexec()
405 args->stk_prot |= PROT_WRITE; in elfexec()
406 if (phdrp->p_flags & PF_X) in elfexec()
407 args->stk_prot |= PROT_EXEC; in elfexec()
422 if (ehdrp->e_type != ET_EXEC) { in elfexec()
427 /* Copy BSS permissions to args->dat_prot */ in elfexec()
429 args->dat_prot = PROT_USER; in elfexec()
430 if (dataphdrp->p_flags & PF_R) in elfexec()
431 args->dat_prot |= PROT_READ; in elfexec()
432 if (dataphdrp->p_flags & PF_W) in elfexec()
433 args->dat_prot |= PROT_WRITE; in elfexec()
434 if (dataphdrp->p_flags & PF_X) in elfexec()
435 args->dat_prot |= PROT_EXEC; in elfexec()
439 * If a auxvector will be required - reserve the space for in elfexec()
441 * ISA-specific types (included in __KERN_NAUXV_IMPL). in elfexec()
445 * If a AUX vector is being built - the base AUX in elfexec()
463 * Has PT_INTERP & PT_PHDR - the auxvectors that in elfexec()
474 args->auxsize = (10 + 5) * sizeof (aux_entry_t); in elfexec()
484 args->auxsize = (10 + 2) * sizeof (aux_entry_t); in elfexec()
486 args->auxsize = 10 * sizeof (aux_entry_t); in elfexec()
489 args->auxsize = 0; in elfexec()
496 if (args->emulator != NULL) in elfexec()
497 args->auxsize += sizeof (aux_entry_t); in elfexec()
508 args->auxsize += 3 * sizeof (aux_entry_t); in elfexec()
517 args->auxsize += 4 * sizeof (aux_entry_t); in elfexec()
521 if ((dynamicphdr != NULL) && (dynamicphdr->p_filesz > 0)) { in elfexec()
522 const size_t dynfilesz = dynamicphdr->p_filesz; in elfexec()
523 const size_t dynoffset = dynamicphdr->p_offset; in elfexec()
537 const size_t remdyns = (dynfilesz - i) / sizeof (*dyn); in elfexec()
553 if (dp->d_tag == DT_SUNW_ASLR) { in elfexec()
556 dp->d_un.d_val)) != 0) { in elfexec()
558 "security-flag from " in elfexec()
572 (capsize = capphdr->p_filesz) > 0 && in elfexec()
579 (ssize_t)capsize, (offset_t)capphdr->p_offset, in elfexec()
586 if (cp->c_tag == CA_SUNW_SF_1 && in elfexec()
587 (cp->c_un.c_val & SF1_SUNW_ADDR32)) { in elfexec()
588 if (args->to_model == DATAMODEL_LP64) in elfexec()
589 args->addr32 = 1; in elfexec()
595 aux = bigwad->elfargs; in elfexec()
601 if (error == -1) { in elfexec()
613 if (ehdrp->e_type == ET_DYN) in elfexec()
629 dynuphdr = (uphdr != NULL && uphdr->p_flags == 0); in elfexec()
648 dlnsize = intphdr->p_filesz; in elfexec()
654 if (intphdr->p_filesz > MAXPATHLEN || dlnsize > MAXPATHLEN || in elfexec()
655 dlnsize == 0 || dlnsize < intphdr->p_filesz) { in elfexec()
663 (ssize_t)intphdr->p_filesz, (offset_t)intphdr->p_offset, in elfexec()
670 if (resid != 0 || dlnp[dlnsize - 1] != '\0') in elfexec()
694 len = p - dlnp - 1; in elfexec()
699 if (_ptr = strrchr(args->pathname, '/')) { in elfexec()
700 len = _ptr - args->pathname; in elfexec()
704 bcopy(args->pathname, &pathbufp[curlen], len); in elfexec()
709 * current directory. So - just substitue in elfexec()
734 if (error && dlnp != bigwad->dl_name) { in elfexec()
735 /* new kernel, old user-level */ in elfexec()
736 error = lookupname(dlnp -= 4, UIO_SYSSPACE, FOLLOW, in elfexec()
748 if (ehdrp->e_type == ET_DYN) { in elfexec()
750 bigwad->exenv.ex_brkbase = (caddr_t)PAGESIZE; in elfexec()
751 bigwad->exenv.ex_bssbase = (caddr_t)PAGESIZE; in elfexec()
753 bigwad->exenv.ex_bssbase = bssbase; in elfexec()
754 bigwad->exenv.ex_brkbase = brkbase; in elfexec()
756 bigwad->exenv.ex_brksize = brksize; in elfexec()
757 bigwad->exenv.ex_magic = elfmagic; in elfexec()
758 bigwad->exenv.ex_vp = vp; in elfexec()
759 setexecenv(&bigwad->exenv); in elfexec()
761 ADDAUX(aux, AT_PHDR, uphdr->p_vaddr + voffset) in elfexec()
762 ADDAUX(aux, AT_PHENT, ehdrp->e_phentsize) in elfexec()
764 ADDAUX(aux, AT_ENTRY, ehdrp->e_entry + voffset) in elfexec()
774 if ((error = execpermissions(nvp, &bigwad->vattr, args)) != 0) { in elfexec()
821 * architecture-specific user per-LWP location. The dtrace in elfexec()
822 * fasttrap provider requires ready access to per-LWP scratch in elfexec()
855 * If the application is set-uid but this is not reflected in elfexec()
857 * don't treat this as a set-uid exec. So we care about in elfexec()
882 args->auxp_auxflags = in elfexec()
883 (char *)((char *)args->stackend + in elfexec()
884 ((char *)&aux->a_type - in elfexec()
885 (char *)bigwad->elfargs)); in elfexec()
891 * (Potentially different between 32-bit and 64-bit ABIs) in elfexec()
893 if (args->to_model == DATAMODEL_NATIVE) { in elfexec()
905 * Reserve space for the brand-private aux vectors, in elfexec()
908 args->auxp_brand = in elfexec()
909 (char *)((char *)args->stackend + in elfexec()
910 ((char *)&aux->a_type - in elfexec()
911 (char *)bigwad->elfargs)); in elfexec()
922 if (args->commpage != (uintptr_t)NULL || in elfexec()
923 (args->commpage = (uintptr_t)comm_page_mapin()) != in elfexec()
925 ADDAUX(aux, AT_SUN_COMMPAGE, args->commpage) in elfexec()
946 postfixsize = (uintptr_t)aux - (uintptr_t)bigwad->elfargs; in elfexec()
956 if (postfixsize != args->auxsize) { in elfexec()
958 size_t, args->auxsize); in elfexec()
965 * For the 64-bit kernel, the limit is big enough that rounding it up in elfexec()
966 * to a page can overflow the 64-bit limit, so we check for btopr() in elfexec()
968 * If it hasn't overflowed, compare the exec size with the rounded up in elfexec()
971 limit = btop(p->p_vmem_ctl); in elfexec()
972 roundlimit = btopr(p->p_vmem_ctl); in elfexec()
975 mutex_enter(&p->p_lock); in elfexec()
976 (void) rctl_action(rctlproc_legacy[RLIMIT_VMEM], p->p_rctls, p, in elfexec()
978 mutex_exit(&p->p_lock); in elfexec()
983 bzero(up->u_auxv, sizeof (up->u_auxv)); in elfexec()
984 up->u_commpagep = args->commpage; in elfexec()
991 error = execpoststack(args, bigwad->elfargs, postfixsize); in elfexec()
997 * If this is a branded process, the brand's exec routine will in elfexec()
1002 ASSERT(num_auxv <= sizeof (up->u_auxv) / sizeof (auxv_t)); in elfexec()
1003 aux = bigwad->elfargs; in elfexec()
1005 up->u_auxv[i].a_type = aux[i].a_type; in elfexec()
1006 up->u_auxv[i].a_un.a_val = (aux_val_t)aux[i].a_un.a_val; in elfexec()
1013 args->entry = (uintptr_t)(ehdrp->e_entry + voffset); in elfexec()
1016 if (ehdrp->e_type == ET_DYN) { in elfexec()
1026 bigwad->exenv.ex_brkbase = (caddr_t)0; in elfexec()
1027 bigwad->exenv.ex_bssbase = (caddr_t)0; in elfexec()
1028 bigwad->exenv.ex_brksize = 0; in elfexec()
1030 bigwad->exenv.ex_brkbase = brkbase; in elfexec()
1031 bigwad->exenv.ex_bssbase = bssbase; in elfexec()
1032 bigwad->exenv.ex_brksize = brksize; in elfexec()
1034 bigwad->exenv.ex_magic = elfmagic; in elfexec()
1035 bigwad->exenv.ex_vp = vp; in elfexec()
1036 setexecenv(&bigwad->exenv); in elfexec()
1043 if (fd != -1) /* did we open the a.out yet */ in elfexec()
1069 const uint_t hsize = ehdrp->e_phentsize; in elfsize()
1075 for (i = nphdrs; i > 0; i--) { in elfsize()
1076 if (phdrp->p_type == PT_LOAD) { in elfsize()
1077 const uintptr_t lo = phdrp->p_vaddr; in elfsize()
1078 const uintptr_t hi = lo + phdrp->p_memsz; in elfsize()
1085 * of a object - used for the AT_SUNW_LDDATA in elfsize()
1089 (phdrp->p_flags & PF_W)) { in elfsize()
1098 /* No non-zero PT_LOAD segment found */ in elfsize()
1102 return (roundup(hiaddr - (loaddr & PAGEMASK), PAGESIZE)); in elfsize()
1128 * Since a separate version is compiled for handling 32-bit and in getelfhead()
1129 * 64-bit ELF executables on a 64-bit kernel, the 64-bit version in getelfhead()
1130 * doesn't need to be able to deal with 32-bit ELF files. in getelfhead()
1133 ehdr->e_ident[EI_MAG2] != ELFMAG2 || in getelfhead()
1134 ehdr->e_ident[EI_MAG3] != ELFMAG3) in getelfhead()
1137 if ((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) || in getelfhead()
1139 ehdr->e_ident[EI_CLASS] != ELFCLASS32 || in getelfhead()
1141 ehdr->e_ident[EI_CLASS] != ELFCLASS64 || in getelfhead()
1143 !elfheadcheck(ehdr->e_ident[EI_DATA], ehdr->e_machine, in getelfhead()
1144 ehdr->e_flags)) in getelfhead()
1147 *nshdrs = ehdr->e_shnum; in getelfhead()
1148 *shstrndx = ehdr->e_shstrndx; in getelfhead()
1149 *nphdrs = ehdr->e_phnum; in getelfhead()
1156 if ((*nshdrs == 0 && ehdr->e_shoff != 0) || in getelfhead()
1160 if (ehdr->e_shoff == 0) in getelfhead()
1164 sizeof (shdr), (offset_t)ehdr->e_shoff, UIO_SYSSPACE, 0, in getelfhead()
1181 * We use members through p_flags on 32-bit files and p_memsz on 64-bit files,
1186 sizeof (((Phdr *)NULL)->p_flags))
1189 sizeof (((Phdr *)NULL)->p_memsz))
1200 * accessible and will maintain 8-byte alignment. in getelfphdr()
1202 if (ehdr->e_phentsize < MINPHENTSZ || (ehdr->e_phentsize & 3)) in getelfphdr()
1205 *phsizep = nphdrs * ehdr->e_phentsize; in getelfphdr()
1215 (offset_t)ehdr->e_phoff, UIO_SYSSPACE, 0, (rlim64_t)0, in getelfphdr()
1226 sizeof (((Shdr *)NULL)->sh_entsize))
1238 * array of section headers, it must be 8-byte aligned or else in getelfshdr()
1240 * sh_entsize (on both 32- and 64-bit ELF files) so e_shentsize in getelfshdr()
1244 if (ehdr->e_shentsize < MINSHDRSZ || (ehdr->e_shentsize & 3) || in getelfshdr()
1249 *shsizep = nshdrs * ehdr->e_shentsize; in getelfshdr()
1259 (offset_t)ehdr->e_shoff, UIO_SYSSPACE, 0, (rlim64_t)0, in getelfshdr()
1269 shdr = (Shdr *)(*shbasep + shstrndx * ehdr->e_shentsize); in getelfshdr()
1270 if ((*shstrsizep = shdr->sh_size) == 0) { in getelfshdr()
1286 (offset_t)shdr->sh_offset, UIO_SYSSPACE, 0, (rlim64_t)0, in getelfshdr()
1294 * Make sure the strtab is null-terminated to make sure we in getelfshdr()
1297 (*shstrbasep)[*shstrsizep - 1] = '\0'; in getelfshdr()
1345 const uint_t hsize = ehdr->e_phentsize; in mapelfexec()
1348 if (ehdr->e_type == ET_DYN) { in mapelfexec()
1369 for (i = nphdrs; i > 0; i--) { in mapelfexec()
1370 if (phdr->p_type == PT_LOAD) { in mapelfexec()
1371 *voffset -= (uintptr_t)phdr->p_vaddr; in mapelfexec()
1382 for (i = nphdrs; i > 0; i--) { in mapelfexec()
1383 switch (phdr->p_type) { in mapelfexec()
1387 if (phdr->p_flags & PF_R) in mapelfexec()
1389 if (phdr->p_flags & PF_W) in mapelfexec()
1391 if (phdr->p_flags & PF_X) in mapelfexec()
1394 addr = (caddr_t)((uintptr_t)phdr->p_vaddr + *voffset); in mapelfexec()
1416 cons->p_flags = 0; in mapelfexec()
1417 cons->p_type = PT_PHDR; in mapelfexec()
1418 cons->p_vaddr = ((uintptr_t)addr - in mapelfexec()
1419 phdr->p_offset) + ehdr->e_phoff; in mapelfexec()
1428 if (phdr->p_filesz > phdr->p_memsz) { in mapelfexec()
1440 zfodsz = (size_t)phdr->p_memsz - phdr->p_filesz; in mapelfexec()
1442 offset = phdr->p_offset; in mapelfexec()
1445 (!(vp->v_flag & VNOMAP))) { in mapelfexec()
1459 phdr->p_filesz, PAGESIZE); in mapelfexec()
1463 phdr->p_filesz + tlen; in mapelfexec()
1471 curproc->p_brkpageszc = in mapelfexec()
1473 curproc, taddr, zfodsz - tlen, 0)); in mapelfexec()
1477 if (curproc->p_brkpageszc != 0 && phdr == dataphdrp && in mapelfexec()
1479 uint_t szc = curproc->p_brkpageszc; in mapelfexec()
1481 caddr_t ebss = addr + phdr->p_memsz; in mapelfexec()
1495 if (error = execmap(vp, addr, phdr->p_filesz, in mapelfexec()
1496 zfodsz + extra_zfodsz, phdr->p_offset, in mapelfexec()
1502 if (error = execmap(vp, addr, phdr->p_filesz, in mapelfexec()
1503 zfodsz, phdr->p_offset, prot, page, 0)) in mapelfexec()
1509 *bssbase = addr + phdr->p_filesz; in mapelfexec()
1512 *brkbase = addr + phdr->p_memsz; in mapelfexec()
1515 memsz = btopr(phdr->p_memsz); in mapelfexec()
1534 if (ptload || phdr->p_flags == 0) in mapelfexec()
1583 *brksize = oend - base; in mapelfexec()
1610 * begins on a 4- or 8-byte boundary for 32- and 64-bit binaries in elfnote()
1612 * at the time of the 64-bit port, both 32- and 64-bit binaries in elfnote()
1613 * descriptions are only guaranteed to begin on a 4-byte boundary. in elfnote()
1638 size_t n = src->sh_size; in elf_copy_scn()
1640 const u_offset_t soff = src->sh_offset; in elf_copy_scn()
1641 const u_offset_t doff = ctx->ecc_doffset; in elf_copy_scn()
1642 void *buf = ctx->ecc_buf; in elf_copy_scn()
1643 vnode_t *dst_vp = ctx->ecc_vp; in elf_copy_scn()
1644 cred_t *credp = ctx->ecc_credp; in elf_copy_scn()
1646 /* Protect the copy loop below from overflow on the offsets */ in elf_copy_scn()
1649 dst->sh_size = 0; in elf_copy_scn()
1650 dst->sh_offset = 0; in elf_copy_scn()
1655 const size_t len = MIN(ctx->ecc_bufsz, n); in elf_copy_scn()
1663 buf, len - resid, ctx->ecc_rlimit, credp) != 0) { in elf_copy_scn()
1664 dst->sh_size = 0; in elf_copy_scn()
1665 dst->sh_offset = 0; in elf_copy_scn()
1669 ASSERT(n >= len - resid); in elf_copy_scn()
1671 n -= len - resid; in elf_copy_scn()
1672 off += len - resid; in elf_copy_scn()
1675 ctx->ecc_doffset += src->sh_size; in elf_copy_scn()
1688 const core_content_t content = ctx->ecc_content; in elf_process_obj_scns()
1689 cred_t *credp = ctx->ecc_credp; in elf_process_obj_scns()
1693 u_offset_t *doffp = &ctx->ecc_doffset; in elf_process_obj_scns()
1727 if (shdr->sh_name >= shstrsize || shdr->sh_type == SHT_NULL) in elf_process_obj_scns()
1730 name = shstrbase + shdr->sh_name; in elf_process_obj_scns()
1735 if (ctf->sh_link != 0 && ctf->sh_link < nshdrs) { in elf_process_obj_scns()
1738 shdr->sh_link * ehdr.e_shentsize); in elf_process_obj_scns()
1773 elf_ctx_resize_scratch(ctx, shdr->sh_size); in elf_process_obj_scns()
1781 v[idx].sh_type = shdr->sh_type; in elf_process_obj_scns()
1782 v[idx].sh_addralign = shdr->sh_addralign; in elf_process_obj_scns()
1785 v[idx].sh_size = shdr->sh_size; in elf_process_obj_scns()
1787 v[idx].sh_entsize = shdr->sh_entsize; in elf_process_obj_scns()
1788 v[idx].sh_info = shdr->sh_info; in elf_process_obj_scns()
1799 if ((symchk->sh_type != SHT_DYNSYM && in elf_process_obj_scns()
1800 symchk->sh_type != SHT_SYMTAB) || in elf_process_obj_scns()
1801 symchk->sh_link == 0 || symchk->sh_link >= nshdrs) { in elf_process_obj_scns()
1805 strchk = (Shdr *)(shbase + symchk->sh_link * ehdr.e_shentsize); in elf_process_obj_scns()
1806 if (strchk->sh_type != SHT_STRTAB) { in elf_process_obj_scns()
1826 if (remain < extra || count > remain - extra) { in elf_process_obj_scns()
1838 elf_ctx_resize_scratch(ctx, ctf->sh_size); in elf_process_obj_scns()
1850 v[idx].sh_size = ctf->sh_size; in elf_process_obj_scns()
1873 MAX(symtab->sh_size, strtab->sh_size)); in elf_process_obj_scns()
1875 if (symtab->sh_type == SHT_DYNSYM) { in elf_process_obj_scns()
1895 v[idx].sh_type = symtab->sh_type; in elf_process_obj_scns()
1896 v[idx].sh_addr = symtab->sh_addr; in elf_process_obj_scns()
1899 v[idx].sh_addralign = symtab->sh_addralign; in elf_process_obj_scns()
1902 v[idx].sh_size = symtab->sh_size; in elf_process_obj_scns()
1904 v[idx].sh_entsize = symtab->sh_entsize; in elf_process_obj_scns()
1905 v[idx].sh_info = symtab->sh_info; in elf_process_obj_scns()
1913 v[idx].sh_addr = strtab->sh_addr; in elf_process_obj_scns()
1916 v[idx].sh_addralign = strtab->sh_addralign; in elf_process_obj_scns()
1919 v[idx].sh_size = strtab->sh_size; in elf_process_obj_scns()
1948 struct as *as = ctx->ecc_p->p_as; in elf_process_scns()
1976 remain--; in elf_process_scns()
1980 caddr_t saddr = seg->s_base, naddr, eaddr; in elf_process_scns()
1991 if (seg->s_ops != &segvn_ops || in elf_process_scns()
1992 SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 || in elf_process_scns()
1993 mvp == lastvp || mvp == NULL || mvp->v_type != VREG || in elf_process_scns()
2019 remain -= count; in elf_process_scns()
2042 ctx->ecc_p->p_pid); in elf_process_scns()
2054 v[idx].sh_offset = ctx->ecc_doffset; in elf_process_scns()
2059 VERIFY3U(ctx->ecc_bufsz, >=, v[idx].sh_size); in elf_process_scns()
2060 shstrtab_dump(&shstrtab, ctx->ecc_buf); in elf_process_scns()
2062 error = core_write(ctx->ecc_vp, UIO_SYSSPACE, ctx->ecc_doffset, in elf_process_scns()
2063 ctx->ecc_buf, v[idx].sh_size, ctx->ecc_rlimit, ctx->ecc_credp); in elf_process_scns()
2065 ctx->ecc_doffset += v[idx].sh_size; in elf_process_scns()
2082 struct as *as = p->p_as; in elfcore()
2148 ehdr->e_ident[EI_MAG0] = ELFMAG0; in elfcore()
2149 ehdr->e_ident[EI_MAG1] = ELFMAG1; in elfcore()
2150 ehdr->e_ident[EI_MAG2] = ELFMAG2; in elfcore()
2151 ehdr->e_ident[EI_MAG3] = ELFMAG3; in elfcore()
2152 ehdr->e_ident[EI_CLASS] = ELFCLASS; in elfcore()
2153 ehdr->e_type = ET_CORE; in elfcore()
2158 ehdr->e_ident[EI_DATA] = ELFDATA2MSB; in elfcore()
2159 ehdr->e_machine = EM_SPARC; in elfcore()
2161 ehdr->e_ident[EI_DATA] = ELFDATA2LSB; in elfcore()
2162 ehdr->e_machine = EM_386; in elfcore()
2170 ehdr->e_ident[EI_DATA] = ELFDATA2MSB; in elfcore()
2171 ehdr->e_machine = EM_SPARCV9; in elfcore()
2173 ehdr->e_ident[EI_DATA] = ELFDATA2LSB; in elfcore()
2174 ehdr->e_machine = EM_AMD64; in elfcore()
2176 #error "no recognized 64-bit machine type is defined" in elfcore()
2194 ehdr->e_phnum = PN_XNUM; in elfcore()
2197 ehdr->e_phnum = (unsigned short)nphdrs; in elfcore()
2202 ehdr->e_shnum = 0; in elfcore()
2205 ehdr->e_shnum = (unsigned short)nshdrs; in elfcore()
2208 if (nshdrs - 1 >= SHN_LORESERVE) { in elfcore()
2209 ehdr->e_shstrndx = SHN_XINDEX; in elfcore()
2210 shdr0.sh_link = nshdrs - 1; in elfcore()
2212 ehdr->e_shstrndx = (unsigned short)(nshdrs - 1); in elfcore()
2215 ehdr->e_shoff = soffset; in elfcore()
2216 ehdr->e_shentsize = sizeof (Shdr); in elfcore()
2219 ehdr->e_ident[EI_VERSION] = EV_CURRENT; in elfcore()
2220 ehdr->e_version = EV_CURRENT; in elfcore()
2221 ehdr->e_ehsize = sizeof (Ehdr); in elfcore()
2222 ehdr->e_phoff = poffset; in elfcore()
2223 ehdr->e_phentsize = sizeof (Phdr); in elfcore()
2241 mutex_enter(&p->p_lock); in elfcore()
2243 brkbase = p->p_brkbase; in elfcore()
2244 brksize = p->p_brksize; in elfcore()
2246 stkbase = p->p_usrstack - p->p_stksize; in elfcore()
2247 stksize = p->p_stksize; in elfcore()
2249 mutex_exit(&p->p_lock); in elfcore()
2254 caddr_t eaddr = seg->s_base + pr_getsegsize(seg, 0); in elfcore()
2259 if ((seg->s_flags & S_HOLE) != 0) { in elfcore()
2263 for (saddr = seg->s_base; saddr < eaddr; saddr = naddr) { in elfcore()
2271 if ((size = (size_t)(naddr - saddr)) == 0) { in elfcore()
2302 } else if (seg->s_ops == &segspt_shmops) { in elfcore()
2311 } else if (seg->s_ops != &segvn_ops) { in elfcore()
2319 } else if (SEGOP_GETVP(seg, seg->s_base, in elfcore()
2321 mvp->v_type != VREG) { in elfcore()
2330 } else if (SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 || in elfcore()
2331 mvp == NULL || mvp->v_type != VREG) { in elfcore()
2369 "process %d; address space is changing", p->p_pid); in elfcore()
2401 * as a zero-filled page such that this is still represented in in elfcore()
2429 towrite -= len; in elfcore()
2440 if ((sig = lwp->lwp_cursig) == 0) { in elfcore()
2472 sq = sig == SIGKILL ? curproc->p_killsqp : lwp->lwp_curinfo; in elfcore()
2475 bcopy(&sq->sq_info, &killinfo.prk_info, in elfcore()
2476 sizeof (sq->sq_info)); in elfcore()
2478 killinfo.prk_info.si_signo = lwp->lwp_cursig; in elfcore()
2484 * If this is a 32-bit process, we need to translate from the in elfcore()
2485 * native siginfo to the 32-bit variant. (Core readers must in elfcore()
2487 * be aware of -- and compensate for -- data model differences.) in elfcore()
2489 if (curproc->p_model == DATAMODEL_ILP32) { in elfcore()
2522 sizeof (Phdr) * (nphdrs - i), rlimit, credp)) != 0) { in elfcore()
2572 &mod_execops, "exec module for elf", &esw
2592 &mod_execops, "32-bit exec module for elf", &esw32