xref: /freebsd/sys/kern/imgact_aout.c (revision f4dc9a4015c8d1239b3a4e06a16aba940fddd9a2)
19454b2d8SWarner Losh /*-
2cfefd687SGarrett Wollman  * Copyright (c) 1993, David Greenman
3cfefd687SGarrett Wollman  * All rights reserved.
4cfefd687SGarrett Wollman  *
5cfefd687SGarrett Wollman  * Redistribution and use in source and binary forms, with or without
6cfefd687SGarrett Wollman  * modification, are permitted provided that the following conditions
7cfefd687SGarrett Wollman  * are met:
8cfefd687SGarrett Wollman  * 1. Redistributions of source code must retain the above copyright
9cfefd687SGarrett Wollman  *    notice, this list of conditions and the following disclaimer.
10cfefd687SGarrett Wollman  * 2. Redistributions in binary form must reproduce the above copyright
11cfefd687SGarrett Wollman  *    notice, this list of conditions and the following disclaimer in the
12cfefd687SGarrett Wollman  *    documentation and/or other materials provided with the distribution.
13cfefd687SGarrett Wollman  *
14cfefd687SGarrett Wollman  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15cfefd687SGarrett Wollman  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16cfefd687SGarrett Wollman  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171984b014SDavid Greenman  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18cfefd687SGarrett Wollman  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19cfefd687SGarrett Wollman  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20cfefd687SGarrett Wollman  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21cfefd687SGarrett Wollman  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22cfefd687SGarrett Wollman  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23cfefd687SGarrett Wollman  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24cfefd687SGarrett Wollman  * SUCH DAMAGE.
25cfefd687SGarrett Wollman  */
26cfefd687SGarrett Wollman 
27677b542eSDavid E. O'Brien #include <sys/cdefs.h>
28677b542eSDavid E. O'Brien __FBSDID("$FreeBSD$");
29677b542eSDavid E. O'Brien 
3026f9a767SRodney W. Grimes #include <sys/param.h>
3126f9a767SRodney W. Grimes #include <sys/exec.h>
3226f9a767SRodney W. Grimes #include <sys/imgact.h>
33bc6d7444SDavid Greenman #include <sys/imgact_aout.h>
3426f9a767SRodney W. Grimes #include <sys/kernel.h>
357332c129SKonstantin Belousov #include <sys/limits.h>
36fb919e4dSMark Murray #include <sys/lock.h>
37e5d6cd0cSBruce Evans #include <sys/malloc.h>
38fb919e4dSMark Murray #include <sys/mutex.h>
39a794e791SBruce Evans #include <sys/proc.h>
401ba5ad42SEdward Tomasz Napierala #include <sys/racct.h>
41fb919e4dSMark Murray #include <sys/resourcevar.h>
4222d4b0fbSJohn Polstra #include <sys/signalvar.h>
4322d4b0fbSJohn Polstra #include <sys/syscall.h>
44e5d6cd0cSBruce Evans #include <sys/sysent.h>
45e5d6cd0cSBruce Evans #include <sys/systm.h>
46a794e791SBruce Evans #include <sys/vnode.h>
47fb919e4dSMark Murray 
48710ded3aSPeter Wemm #include <machine/frame.h>
49e5d6cd0cSBruce Evans #include <machine/md_var.h>
50cfefd687SGarrett Wollman 
5126f9a767SRodney W. Grimes #include <vm/vm.h>
52efeaf95aSDavid Greenman #include <vm/pmap.h>
53efeaf95aSDavid Greenman #include <vm/vm_map.h>
541616db3cSJohn Dyson #include <vm/vm_object.h>
55e5d6cd0cSBruce Evans #include <vm/vm_param.h>
56cfefd687SGarrett Wollman 
577332c129SKonstantin Belousov #ifdef __amd64__
587332c129SKonstantin Belousov #include <compat/freebsd32/freebsd32_signal.h>
597332c129SKonstantin Belousov #include <compat/freebsd32/freebsd32_util.h>
607332c129SKonstantin Belousov #include <compat/freebsd32/freebsd32_proto.h>
617332c129SKonstantin Belousov #include <compat/freebsd32/freebsd32_syscall.h>
627332c129SKonstantin Belousov #include <compat/ia32/ia32_signal.h>
637332c129SKonstantin Belousov #endif
647332c129SKonstantin Belousov 
654d77a549SAlfred Perlstein static int	exec_aout_imgact(struct image_params *imgp);
66f36ba452SJake Burkholder static int	aout_fixup(register_t **stack_base, struct image_params *imgp);
677ee050b7SBruce Evans 
687332c129SKonstantin Belousov #if defined(__i386__)
6922d4b0fbSJohn Polstra struct sysentvec aout_sysvec = {
70a8d403e1SKonstantin Belousov 	.sv_size	= SYS_MAXSYSCALL,
71a8d403e1SKonstantin Belousov 	.sv_table	= sysent,
72a8d403e1SKonstantin Belousov 	.sv_mask	= 0,
73a8d403e1SKonstantin Belousov 	.sv_sigsize	= 0,
74a8d403e1SKonstantin Belousov 	.sv_sigtbl	= NULL,
75a8d403e1SKonstantin Belousov 	.sv_errsize	= 0,
76a8d403e1SKonstantin Belousov 	.sv_errtbl	= NULL,
77a8d403e1SKonstantin Belousov 	.sv_transtrap	= NULL,
78a8d403e1SKonstantin Belousov 	.sv_fixup	= aout_fixup,
79a8d403e1SKonstantin Belousov 	.sv_sendsig	= sendsig,
80a8d403e1SKonstantin Belousov 	.sv_sigcode	= sigcode,
81a8d403e1SKonstantin Belousov 	.sv_szsigcode	= &szsigcode,
82a8d403e1SKonstantin Belousov 	.sv_prepsyscall	= NULL,
83a8d403e1SKonstantin Belousov 	.sv_name	= "FreeBSD a.out",
84a8d403e1SKonstantin Belousov 	.sv_coredump	= NULL,
85a8d403e1SKonstantin Belousov 	.sv_imgact_try	= NULL,
86a8d403e1SKonstantin Belousov 	.sv_minsigstksz	= MINSIGSTKSZ,
87a8d403e1SKonstantin Belousov 	.sv_pagesize	= PAGE_SIZE,
88a8d403e1SKonstantin Belousov 	.sv_minuser	= VM_MIN_ADDRESS,
89a8d403e1SKonstantin Belousov 	.sv_maxuser	= VM_MAXUSER_ADDRESS,
90a8d403e1SKonstantin Belousov 	.sv_usrstack	= USRSTACK,
91a8d403e1SKonstantin Belousov 	.sv_psstrings	= PS_STRINGS,
92a8d403e1SKonstantin Belousov 	.sv_stackprot	= VM_PROT_ALL,
93a8d403e1SKonstantin Belousov 	.sv_copyout_strings	= exec_copyout_strings,
94a8d403e1SKonstantin Belousov 	.sv_setregs	= exec_setregs,
95a8d403e1SKonstantin Belousov 	.sv_fixlimit	= NULL,
96b4cf0e62SKonstantin Belousov 	.sv_maxssiz	= NULL,
977332c129SKonstantin Belousov 	.sv_flags	= SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32,
98afe1a688SKonstantin Belousov 	.sv_set_syscall_retval = cpu_set_syscall_retval,
99afe1a688SKonstantin Belousov 	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
100afe1a688SKonstantin Belousov 	.sv_syscallnames = syscallnames,
101e5d81ef1SDmitry Chagin 	.sv_schedtail	= NULL,
10222d4b0fbSJohn Polstra };
10322d4b0fbSJohn Polstra 
1047332c129SKonstantin Belousov #elif defined(__amd64__)
1057332c129SKonstantin Belousov 
1065a888c06SKonstantin Belousov #define	AOUT32_USRSTACK	0xbfc00000
1077332c129SKonstantin Belousov #define	AOUT32_PS_STRINGS \
1087332c129SKonstantin Belousov     (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings))
1097332c129SKonstantin Belousov 
1107332c129SKonstantin Belousov extern const char *freebsd32_syscallnames[];
1117332c129SKonstantin Belousov extern u_long ia32_maxssiz;
1127332c129SKonstantin Belousov 
1137332c129SKonstantin Belousov struct sysentvec aout_sysvec = {
1147332c129SKonstantin Belousov 	.sv_size	= FREEBSD32_SYS_MAXSYSCALL,
1157332c129SKonstantin Belousov 	.sv_table	= freebsd32_sysent,
1167332c129SKonstantin Belousov 	.sv_mask	= 0,
1177332c129SKonstantin Belousov 	.sv_sigsize	= 0,
1187332c129SKonstantin Belousov 	.sv_sigtbl	= NULL,
1197332c129SKonstantin Belousov 	.sv_errsize	= 0,
1207332c129SKonstantin Belousov 	.sv_errtbl	= NULL,
1217332c129SKonstantin Belousov 	.sv_transtrap	= NULL,
1227332c129SKonstantin Belousov 	.sv_fixup	= aout_fixup,
1237332c129SKonstantin Belousov 	.sv_sendsig	= ia32_sendsig,
1247332c129SKonstantin Belousov 	.sv_sigcode	= ia32_sigcode,
1257332c129SKonstantin Belousov 	.sv_szsigcode	= &sz_ia32_sigcode,
1267332c129SKonstantin Belousov 	.sv_prepsyscall	= NULL,
1277332c129SKonstantin Belousov 	.sv_name	= "FreeBSD a.out",
1287332c129SKonstantin Belousov 	.sv_coredump	= NULL,
1297332c129SKonstantin Belousov 	.sv_imgact_try	= NULL,
1307332c129SKonstantin Belousov 	.sv_minsigstksz	= MINSIGSTKSZ,
1317332c129SKonstantin Belousov 	.sv_pagesize	= IA32_PAGE_SIZE,
1327332c129SKonstantin Belousov 	.sv_minuser	= 0,
1337332c129SKonstantin Belousov 	.sv_maxuser	= AOUT32_USRSTACK,
1347332c129SKonstantin Belousov 	.sv_usrstack	= AOUT32_USRSTACK,
1357332c129SKonstantin Belousov 	.sv_psstrings	= AOUT32_PS_STRINGS,
1367332c129SKonstantin Belousov 	.sv_stackprot	= VM_PROT_ALL,
1377332c129SKonstantin Belousov 	.sv_copyout_strings	= freebsd32_copyout_strings,
1387332c129SKonstantin Belousov 	.sv_setregs	= ia32_setregs,
1397332c129SKonstantin Belousov 	.sv_fixlimit	= ia32_fixlimit,
1407332c129SKonstantin Belousov 	.sv_maxssiz	= &ia32_maxssiz,
1417332c129SKonstantin Belousov 	.sv_flags	= SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32,
1427332c129SKonstantin Belousov 	.sv_set_syscall_retval = ia32_set_syscall_retval,
1437332c129SKonstantin Belousov 	.sv_fetch_syscall_args = ia32_fetch_syscall_args,
1447332c129SKonstantin Belousov 	.sv_syscallnames = freebsd32_syscallnames,
1457332c129SKonstantin Belousov };
1467332c129SKonstantin Belousov #else
1477332c129SKonstantin Belousov #error "Port me"
1487332c129SKonstantin Belousov #endif
1497332c129SKonstantin Belousov 
150b9e91a85SBruce Evans static int
1517332c129SKonstantin Belousov aout_fixup(register_t **stack_base, struct image_params *imgp)
152f36ba452SJake Burkholder {
153f36ba452SJake Burkholder 
1547332c129SKonstantin Belousov 	*(char **)stack_base -= sizeof(uint32_t);
155508462edSKonstantin Belousov 	return (suword32(*stack_base, imgp->args->argc));
156f36ba452SJake Burkholder }
157f36ba452SJake Burkholder 
158f36ba452SJake Burkholder static int
1597332c129SKonstantin Belousov exec_aout_imgact(struct image_params *imgp)
160cfefd687SGarrett Wollman {
161e0c95ed9SBruce Evans 	const struct exec *a_out = (const struct exec *) imgp->image_header;
1625856e12eSJohn Dyson 	struct vmspace *vmspace;
1632f33b2c0SAlan Cox 	vm_map_t map;
1641616db3cSJohn Dyson 	vm_object_t object;
1651616db3cSJohn Dyson 	vm_offset_t text_end, data_end;
166ede8dc43SBruce Evans 	unsigned long virtual_offset;
167a316d390SJohn Dyson 	unsigned long file_offset;
168cfefd687SGarrett Wollman 	unsigned long bss_size;
169bb56ec4aSPoul-Henning Kamp 	int error;
170cfefd687SGarrett Wollman 
1711e1e0b44SSøren Schmidt 	/*
1721e1e0b44SSøren Schmidt 	 * Linux and *BSD binaries look very much alike,
1731e1e0b44SSøren Schmidt 	 * only the machine id is different:
174d3628763SRodney W. Grimes 	 * 0x64 for Linux, 0x86 for *BSD, 0x00 for BSDI.
175185dc761SPeter Wemm 	 * NetBSD is in network byte order.. ugh.
1761e1e0b44SSøren Schmidt 	 */
177*f4dc9a40SWarner Losh 	if (((a_out->a_midmag >> 16) & 0xff) != 0x86 &&
178*f4dc9a40SWarner Losh 	    ((a_out->a_midmag >> 16) & 0xff) != 0 &&
179*f4dc9a40SWarner Losh 	    ((((int)ntohl(a_out->a_midmag)) >> 16) & 0xff) != 0x86)
1801e1e0b44SSøren Schmidt                 return -1;
1811e1e0b44SSøren Schmidt 
182cfefd687SGarrett Wollman 	/*
183cfefd687SGarrett Wollman 	 * Set file/virtual offset based on a.out variant.
184cfefd687SGarrett Wollman 	 *	We do two cases: host byte order and network byte order
185cfefd687SGarrett Wollman 	 *	(for NetBSD compatibility)
186cfefd687SGarrett Wollman 	 */
187*f4dc9a40SWarner Losh 	switch ((int)(a_out->a_midmag & 0xffff)) {
188cfefd687SGarrett Wollman 	case ZMAGIC:
189cfefd687SGarrett Wollman 		virtual_offset = 0;
190cfefd687SGarrett Wollman 		if (a_out->a_text) {
191f8845af0SPoul-Henning Kamp 			file_offset = PAGE_SIZE;
192cfefd687SGarrett Wollman 		} else {
193cfefd687SGarrett Wollman 			/* Bill's "screwball mode" */
194cfefd687SGarrett Wollman 			file_offset = 0;
195cfefd687SGarrett Wollman 		}
196cfefd687SGarrett Wollman 		break;
197cfefd687SGarrett Wollman 	case QMAGIC:
198f8845af0SPoul-Henning Kamp 		virtual_offset = PAGE_SIZE;
199cfefd687SGarrett Wollman 		file_offset = 0;
2004fe88fe6SJohn Polstra 		/* Pass PS_STRINGS for BSD/OS binaries only. */
2014fe88fe6SJohn Polstra 		if (N_GETMID(*a_out) == MID_ZERO)
20205ba50f5SJake Burkholder 			imgp->ps_strings = aout_sysvec.sv_psstrings;
203cfefd687SGarrett Wollman 		break;
204cfefd687SGarrett Wollman 	default:
205cfefd687SGarrett Wollman 		/* NetBSD compatibility */
206*f4dc9a40SWarner Losh 		switch ((int)(ntohl(a_out->a_midmag) & 0xffff)) {
207cfefd687SGarrett Wollman 		case ZMAGIC:
208cfefd687SGarrett Wollman 		case QMAGIC:
209f8845af0SPoul-Henning Kamp 			virtual_offset = PAGE_SIZE;
210cfefd687SGarrett Wollman 			file_offset = 0;
211cfefd687SGarrett Wollman 			break;
212cfefd687SGarrett Wollman 		default:
213cfefd687SGarrett Wollman 			return (-1);
214cfefd687SGarrett Wollman 		}
215cfefd687SGarrett Wollman 	}
216cfefd687SGarrett Wollman 
217f8845af0SPoul-Henning Kamp 	bss_size = roundup(a_out->a_bss, PAGE_SIZE);
218cfefd687SGarrett Wollman 
219cfefd687SGarrett Wollman 	/*
220cfefd687SGarrett Wollman 	 * Check various fields in header for validity/bounds.
221cfefd687SGarrett Wollman 	 */
222cfefd687SGarrett Wollman 	if (/* entry point must lay with text region */
223cfefd687SGarrett Wollman 	    a_out->a_entry < virtual_offset ||
224cfefd687SGarrett Wollman 	    a_out->a_entry >= virtual_offset + a_out->a_text ||
225cfefd687SGarrett Wollman 
226cfefd687SGarrett Wollman 	    /* text and data size must each be page rounded */
2277332c129SKonstantin Belousov 	    a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK
2287332c129SKonstantin Belousov 
2297332c129SKonstantin Belousov #ifdef __amd64__
2307332c129SKonstantin Belousov 	    ||
2317332c129SKonstantin Belousov 	    /* overflows */
2327332c129SKonstantin Belousov 	    virtual_offset + a_out->a_text + a_out->a_data + bss_size > UINT_MAX
2337332c129SKonstantin Belousov #endif
2347332c129SKonstantin Belousov 	    )
235cfefd687SGarrett Wollman 		return (-1);
236cfefd687SGarrett Wollman 
237cfefd687SGarrett Wollman 	/* text + data can't exceed file size */
238c52007c2SDavid Greenman 	if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
239cfefd687SGarrett Wollman 		return (EFAULT);
240cfefd687SGarrett Wollman 
241cfefd687SGarrett Wollman 	/*
242cfefd687SGarrett Wollman 	 * text/data/bss must not exceed limits
243cfefd687SGarrett Wollman 	 */
24491d5354aSJohn Baldwin 	PROC_LOCK(imgp->proc);
245cfefd687SGarrett Wollman 	if (/* text can't exceed maximum text size */
246cbc89bfbSPaul Saab 	    a_out->a_text > maxtsiz ||
247cfefd687SGarrett Wollman 
248cfefd687SGarrett Wollman 	    /* data + bss can't exceed rlimit */
2491ba5ad42SEdward Tomasz Napierala 	    a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
2501ba5ad42SEdward Tomasz Napierala 	    racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {
25191d5354aSJohn Baldwin 			PROC_UNLOCK(imgp->proc);
252cfefd687SGarrett Wollman 			return (ENOMEM);
25391d5354aSJohn Baldwin 	}
25491d5354aSJohn Baldwin 	PROC_UNLOCK(imgp->proc);
255cfefd687SGarrett Wollman 
256cfefd687SGarrett Wollman 	/*
25760bb3943SAlan Cox 	 * Avoid a possible deadlock if the current address space is destroyed
25860bb3943SAlan Cox 	 * and that address space maps the locked vnode.  In the common case,
25960bb3943SAlan Cox 	 * the locked vnode's v_usecount is decremented but remains greater
26060bb3943SAlan Cox 	 * than zero.  Consequently, the vnode lock is not needed by vrele().
26160bb3943SAlan Cox 	 * However, in cases where the vnode lock is external, such as nullfs,
26260bb3943SAlan Cox 	 * v_usecount may become zero.
26360bb3943SAlan Cox 	 */
26422db15c0SAttilio Rao 	VOP_UNLOCK(imgp->vp, 0);
26560bb3943SAlan Cox 
26660bb3943SAlan Cox 	/*
267cfefd687SGarrett Wollman 	 * Destroy old process VM and create a new one (with a new stack)
268cfefd687SGarrett Wollman 	 */
26989b57fcfSKonstantin Belousov 	error = exec_new_vmspace(imgp, &aout_sysvec);
270cfefd687SGarrett Wollman 
271cb05b60aSAttilio Rao 	vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
27289b57fcfSKonstantin Belousov 	if (error)
27389b57fcfSKonstantin Belousov 		return (error);
27460bb3943SAlan Cox 
275cfefd687SGarrett Wollman 	/*
2765856e12eSJohn Dyson 	 * The vm space can be changed by exec_new_vmspace
2775856e12eSJohn Dyson 	 */
2785856e12eSJohn Dyson 	vmspace = imgp->proc->p_vmspace;
2795856e12eSJohn Dyson 
2800b2ed1aeSJeff Roberson 	object = imgp->object;
2812f33b2c0SAlan Cox 	map = &vmspace->vm_map;
2822f33b2c0SAlan Cox 	vm_map_lock(map);
2831616db3cSJohn Dyson 	vm_object_reference(object);
2841616db3cSJohn Dyson 
2851616db3cSJohn Dyson 	text_end = virtual_offset + a_out->a_text;
2860a91231dSAlan Cox 	error = vm_map_insert(map, object,
2871616db3cSJohn Dyson 		file_offset,
2881616db3cSJohn Dyson 		virtual_offset, text_end,
2891616db3cSJohn Dyson 		VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL,
290e972780aSAlan Cox 		MAP_COPY_ON_WRITE | MAP_PREFAULT);
2912f33b2c0SAlan Cox 	if (error) {
2922f33b2c0SAlan Cox 		vm_map_unlock(map);
29341634e2eSAlan Cox 		vm_object_deallocate(object);
294cfefd687SGarrett Wollman 		return (error);
2952f33b2c0SAlan Cox 	}
2961616db3cSJohn Dyson 	data_end = text_end + a_out->a_data;
2971616db3cSJohn Dyson 	if (a_out->a_data) {
2981616db3cSJohn Dyson 		vm_object_reference(object);
2990a91231dSAlan Cox 		error = vm_map_insert(map, object,
3001616db3cSJohn Dyson 			file_offset + a_out->a_text,
3011616db3cSJohn Dyson 			text_end, data_end,
3021616db3cSJohn Dyson 			VM_PROT_ALL, VM_PROT_ALL,
303e972780aSAlan Cox 			MAP_COPY_ON_WRITE | MAP_PREFAULT);
3042f33b2c0SAlan Cox 		if (error) {
3052f33b2c0SAlan Cox 			vm_map_unlock(map);
30641634e2eSAlan Cox 			vm_object_deallocate(object);
3071616db3cSJohn Dyson 			return (error);
3081616db3cSJohn Dyson 		}
3092f33b2c0SAlan Cox 	}
310cfefd687SGarrett Wollman 
3111616db3cSJohn Dyson 	if (bss_size) {
3120a91231dSAlan Cox 		error = vm_map_insert(map, NULL, 0,
3131616db3cSJohn Dyson 			data_end, data_end + bss_size,
3141616db3cSJohn Dyson 			VM_PROT_ALL, VM_PROT_ALL, 0);
3152f33b2c0SAlan Cox 		if (error) {
3162f33b2c0SAlan Cox 			vm_map_unlock(map);
317cfefd687SGarrett Wollman 			return (error);
31868940ac1SDavid Greenman 		}
3192f33b2c0SAlan Cox 	}
3202f33b2c0SAlan Cox 	vm_map_unlock(map);
321cfefd687SGarrett Wollman 
322cfefd687SGarrett Wollman 	/* Fill in process VM information */
323cfefd687SGarrett Wollman 	vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT;
324cfefd687SGarrett Wollman 	vmspace->vm_dsize = (a_out->a_data + bss_size) >> PAGE_SHIFT;
3257cd99438SBruce Evans 	vmspace->vm_taddr = (caddr_t) (uintptr_t) virtual_offset;
3267cd99438SBruce Evans 	vmspace->vm_daddr = (caddr_t) (uintptr_t)
3277cd99438SBruce Evans 			    (virtual_offset + a_out->a_text);
328cfefd687SGarrett Wollman 
329cfefd687SGarrett Wollman 	/* Fill in image_params */
330c52007c2SDavid Greenman 	imgp->interpreted = 0;
331c52007c2SDavid Greenman 	imgp->entry_addr = a_out->a_entry;
332cfefd687SGarrett Wollman 
333c52007c2SDavid Greenman 	imgp->proc->p_sysent = &aout_sysvec;
334c0e5de7dSDavid Greenman 
335cfefd687SGarrett Wollman 	return (0);
336cfefd687SGarrett Wollman }
33792d91f76SGarrett Wollman 
33892d91f76SGarrett Wollman /*
33992d91f76SGarrett Wollman  * Tell kern_execve.c about it, with a little help from the linker.
34092d91f76SGarrett Wollman  */
341820ca326SMatthew Dillon static struct execsw aout_execsw = { exec_aout_imgact, "a.out" };
342aa855a59SPeter Wemm EXEC_SET(aout, aout_execsw);
343