&ph[i], &addr, &size, &prot);
&ph[i], &addr, &size, &prot, 0);
ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp){	Elf_Ehdr *eh = epp->ep_hdr;	Elf_Phdr *ph, *pp;	Elf_Addr phdr = 0;	int error, i, nload;	char interp[MAXPATHLEN];	u_long pos = 0, phsize;	u_int8_t os = OOS_NULL;	if (epp->ep_hdrvalid < sizeof(Elf_Ehdr))		return (ENOEXEC);	if (ELFNAME(check_header)(eh, ET_EXEC) &&	    ELFNAME(olf_check_header)(eh, ET_EXEC, &os))		return (ENOEXEC);	/*	 * check if vnode is in open for writing, because we want to demand-	 * page out of it.  if it is, don't do it, for various reasons.	 */	if (epp->ep_vp->v_writecount != 0) {#ifdef DIAGNOSTIC		if (epp->ep_vp->v_flag & VTEXT)			panic("exec: a VTEXT vnode has writecount != 0");#endif		return (ETXTBSY);	}	/*	 * Allocate space to hold all the program headers, and read them	 * from the file	 */	phsize = eh->e_phnum * sizeof(Elf_Phdr);	ph = (Elf_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);	if ((error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff, (caddr_t)ph,	    phsize)) != 0)		goto bad;	epp->ep_tsize = ELFDEFNNAME(NO_ADDR);	epp->ep_dsize = ELFDEFNNAME(NO_ADDR);	interp[0] = '\0';	for (i = 0; i < eh->e_phnum; i++) {		pp = &ph[i];		if (pp->p_type == PT_INTERP) {			if (pp->p_filesz >= sizeof(interp))				goto bad;			if ((error = ELFNAME(read_from)(p, epp->ep_vp,			    pp->p_offset, (caddr_t)interp, pp->p_filesz)) != 0)				goto bad;			break;		}	}	/*	 * OK, we want a slightly different twist of the	 * standard emulation package for "real" elf.	 */	epp->ep_emul = &ELFNAMEEND(emul);	pos = ELFDEFNNAME(NO_ADDR);	/*	 * On the same architecture, we may be emulating different systems.	 * See which one will accept this executable.	 *	 * Probe functions would normally see if the interpreter (if any)	 * exists. Emulation packages may possibly replace the interpreter in	 * interp[] with a changed path (/emul/xxx/<path>), and also	 * set the ep_emul field in the exec package structure.	 */	error = ENOEXEC;	p->p_os = OOS_OPENBSD;#ifdef NATIVE_EXEC_ELF	if (ELFNAME(os_pt_note)(p, epp, epp->ep_hdr, "OpenBSD", 8, 4) == 0) {		goto native;	}#endif	for (i = 0;	    i < sizeof(ELFNAME(probes)) / sizeof(ELFNAME(probes)[0]) && error;	    i++) {		if (os == OOS_NULL || ((1 << os) & ELFNAME(probes)[i].os_mask))			error = ELFNAME(probes)[i].func ?			    (*ELFNAME(probes)[i].func)(p, epp, interp, &pos, &os) :			    0;	}	if (!error)		p->p_os = os;#ifndef NATIVE_EXEC_ELF	else		goto bad;#elsenative:#endif /* NATIVE_EXEC_ELF */	/*	 * Load all the necessary sections	 */	for (i = nload = 0; i < eh->e_phnum; i++) {		Elf_Addr addr = ELFDEFNNAME(NO_ADDR), size = 0;		int prot = 0;		pp = &ph[i];		switch (ph[i].p_type) {		case PT_LOAD:			/*			 * XXX			 * Can handle only 2 sections: text and data			 */			if (nload++ == 2)				goto bad;			ELFNAME(load_psection)(&epp->ep_vmcmds, epp->ep_vp,			    &ph[i], &addr, &size, &prot);			/*			 * Decide whether it's text or data by looking			 * at the entry point.			 */			if (eh->e_entry >= addr &&			    eh->e_entry < (addr + size)) {				epp->ep_taddr = addr;				epp->ep_tsize = size;				if (epp->ep_daddr == ELFDEFNNAME(NO_ADDR)) {					epp->ep_daddr = addr;					epp->ep_dsize = size;				}			} else {				epp->ep_daddr = addr;				epp->ep_dsize = size;			}			break;		case PT_SHLIB:			error = ENOEXEC;			goto bad;		case PT_INTERP:			/* Already did this one */		case PT_DYNAMIC:		case PT_NOTE:			break;		case PT_PHDR:			/* Note address of program headers (in text segment) */			phdr = pp->p_vaddr;			break;		default:			/*			 * Not fatal, we don't need to understand everything			 * :-)			 */			break;		}	}#if !defined(__mips__)	/*	 * If no position to load the interpreter was set by a probe	 * function, pick the same address that a non-fixed mmap(0, ..)	 * would (i.e. something safely out of the way).	 */	if (pos == ELFDEFNNAME(NO_ADDR))		pos = round_page(epp->ep_daddr + MAXDSIZ);#endif	/*	 * Check if we found a dynamically linked binary and arrange to load	 * it's interpreter when the exec file is released.	 */	if (interp[0]) {		char *ip;		struct elf_args *ap;		ip = (char *)malloc(MAXPATHLEN, M_TEMP, M_WAITOK);		ap = (struct elf_args *)		    malloc(sizeof(struct elf_args), M_TEMP, M_WAITOK);		bcopy(interp, ip, MAXPATHLEN);		epp->ep_interp = ip;		epp->ep_interp_pos = pos;		ap->arg_phaddr = phdr;		ap->arg_phentsize = eh->e_phentsize;		ap->arg_phnum = eh->e_phnum;		ap->arg_entry = eh->e_entry;		ap->arg_os = os;		epp->ep_emul_arg = ap;		epp->ep_entry = eh->e_entry; /* keep check_exec() happy */	} else {		epp->ep_interp = NULL;		epp->ep_entry = eh->e_entry;	}#if defined(COMPAT_SVR4) && defined(i386)#ifndef ELF_MAP_PAGE_ZERO	/* Dell SVR4 maps page zero, yeuch! */	if (p->p_os == OOS_DELL)#endif		NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, PAGE_SIZE, 0,		    epp->ep_vp, 0, VM_PROT_READ);#endif	free((char *)ph, M_TEMP);	vn_marktext(epp->ep_vp);	return (exec_setup_stack(p, epp));bad:	free((char *)ph, M_TEMP);	kill_vmcmds(&epp->ep_vmcmds);	return (ENOEXEC);}