1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: imgact_aout.c,v 1.37 1998/01/06 05:15:25 dyson Exp $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/resourcevar.h> 31#include <sys/exec.h> 32#include <sys/mman.h> 33#include <sys/imgact.h> 34#include <sys/imgact_aout.h> 35#include <sys/kernel.h> 36#include <sys/proc.h> 37#include <sys/sysent.h> 38#include <sys/vnode.h> |
39#include <sys/systm.h> |
40 41#include <vm/vm.h> 42#include <vm/vm_param.h> 43#include <vm/vm_prot.h> 44#include <sys/lock.h> 45#include <vm/pmap.h> 46#include <vm/vm_map.h> |
47#include <vm/vm_object.h> |
48#include <vm/vm_extern.h> 49 50static int exec_aout_imgact __P((struct image_params *imgp)); 51 52int 53exec_aout_imgact(imgp) 54 struct image_params *imgp; 55{ 56 const struct exec *a_out = (const struct exec *) imgp->image_header; 57 struct vmspace *vmspace; |
58 struct vnode *vp; 59 vm_object_t object; 60 vm_offset_t text_end, data_end; |
61 unsigned long virtual_offset; 62 unsigned long file_offset; 63 unsigned long bss_size; 64 int error; 65 66 /* 67 * Linux and *BSD binaries look very much alike, 68 * only the machine id is different: --- 75 unchanged lines hidden (view full) --- 144 */ 145 exec_new_vmspace(imgp); 146 147 /* 148 * The vm space can be changed by exec_new_vmspace 149 */ 150 vmspace = imgp->proc->p_vmspace; 151 |
152 vp = imgp->vp; 153 object = vp->v_object; 154 vm_object_reference(object); 155 156 text_end = virtual_offset + a_out->a_text; 157 error = vm_map_insert(&vmspace->vm_map, object, 158 file_offset, 159 virtual_offset, text_end, 160 VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL, 161 MAP_COPY_NEEDED | MAP_COPY_ON_WRITE); |
162 if (error) 163 return (error); 164 |
165 data_end = text_end + a_out->a_data; 166 if (a_out->a_data) { 167 vm_object_reference(object); 168 error = vm_map_insert(&vmspace->vm_map, object, 169 file_offset + a_out->a_text, 170 text_end, data_end, 171 VM_PROT_ALL, VM_PROT_ALL, 172 MAP_COPY_NEEDED | MAP_COPY_ON_WRITE); |
173 if (error) 174 return (error); 175 } 176 |
177 pmap_object_init_pt(&vmspace->vm_pmap, virtual_offset, 178 object, (vm_pindex_t) OFF_TO_IDX(file_offset), 179 a_out->a_text + a_out->a_data, 0); 180 181 if (bss_size) { 182 error = vm_map_insert(&vmspace->vm_map, NULL, 0, 183 data_end, data_end + bss_size, 184 VM_PROT_ALL, VM_PROT_ALL, 0); 185 if (error) 186 return (error); 187 } 188 |
189 /* Fill in process VM information */ 190 vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT; 191 vmspace->vm_dsize = (a_out->a_data + bss_size) >> PAGE_SHIFT; 192 vmspace->vm_taddr = (caddr_t) virtual_offset; 193 vmspace->vm_daddr = (caddr_t) virtual_offset + a_out->a_text; 194 195 /* Fill in image_params */ 196 imgp->interpreted = 0; --- 17 unchanged lines hidden --- |