imgact_aout.c (76827) | imgact_aout.c (79224) |
---|---|
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 * | 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 * $FreeBSD: head/sys/kern/imgact_aout.c 76827 2001-05-19 01:28:09Z alfred $ | 26 * $FreeBSD: head/sys/kern/imgact_aout.c 79224 2001-07-04 16:20:28Z dillon $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/exec.h> 31#include <sys/fcntl.h> 32#include <sys/imgact.h> 33#include <sys/imgact_aout.h> 34#include <sys/kernel.h> --- 51 unchanged lines hidden (view full) --- 86 vm_map_t map; 87 vm_object_t object; 88 vm_offset_t text_end, data_end; 89 unsigned long virtual_offset; 90 unsigned long file_offset; 91 unsigned long bss_size; 92 int error; 93 | 27 */ 28 29#include <sys/param.h> 30#include <sys/exec.h> 31#include <sys/fcntl.h> 32#include <sys/imgact.h> 33#include <sys/imgact_aout.h> 34#include <sys/kernel.h> --- 51 unchanged lines hidden (view full) --- 86 vm_map_t map; 87 vm_object_t object; 88 vm_offset_t text_end, data_end; 89 unsigned long virtual_offset; 90 unsigned long file_offset; 91 unsigned long bss_size; 92 int error; 93 |
94 GIANT_REQUIRED; 95 |
|
94 /* 95 * Linux and *BSD binaries look very much alike, 96 * only the machine id is different: 97 * 0x64 for Linux, 0x86 for *BSD, 0x00 for BSDI. 98 * NetBSD is in network byte order.. ugh. 99 */ 100 if (((a_out->a_magic >> 16) & 0xff) != 0x86 && 101 ((a_out->a_magic >> 16) & 0xff) != 0 && --- 64 unchanged lines hidden (view full) --- 166 imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur) 167 return (ENOMEM); 168 169 /* copy in arguments and/or environment from old process */ 170 error = exec_extract_strings(imgp); 171 if (error) 172 return (error); 173 | 96 /* 97 * Linux and *BSD binaries look very much alike, 98 * only the machine id is different: 99 * 0x64 for Linux, 0x86 for *BSD, 0x00 for BSDI. 100 * NetBSD is in network byte order.. ugh. 101 */ 102 if (((a_out->a_magic >> 16) & 0xff) != 0x86 && 103 ((a_out->a_magic >> 16) & 0xff) != 0 && --- 64 unchanged lines hidden (view full) --- 168 imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur) 169 return (ENOMEM); 170 171 /* copy in arguments and/or environment from old process */ 172 error = exec_extract_strings(imgp); 173 if (error) 174 return (error); 175 |
174 mtx_lock(&vm_mtx); | |
175 /* 176 * Destroy old process VM and create a new one (with a new stack) 177 */ 178 exec_new_vmspace(imgp); 179 180 /* 181 * The vm space can be changed by exec_new_vmspace 182 */ 183 vmspace = imgp->proc->p_vmspace; 184 185 vp = imgp->vp; 186 map = &vmspace->vm_map; 187 vm_map_lock(map); | 176 /* 177 * Destroy old process VM and create a new one (with a new stack) 178 */ 179 exec_new_vmspace(imgp); 180 181 /* 182 * The vm space can be changed by exec_new_vmspace 183 */ 184 vmspace = imgp->proc->p_vmspace; 185 186 vp = imgp->vp; 187 map = &vmspace->vm_map; 188 vm_map_lock(map); |
188 mtx_unlock(&vm_mtx); | |
189 VOP_GETVOBJECT(vp, &object); | 189 VOP_GETVOBJECT(vp, &object); |
190 mtx_lock(&vm_mtx); | |
191 vm_object_reference(object); 192 193 text_end = virtual_offset + a_out->a_text; 194 error = vm_map_insert(map, object, 195 file_offset, 196 virtual_offset, text_end, 197 VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL, 198 MAP_COPY_ON_WRITE | MAP_PREFAULT); 199 if (error) { 200 vm_map_unlock(map); | 190 vm_object_reference(object); 191 192 text_end = virtual_offset + a_out->a_text; 193 error = vm_map_insert(map, object, 194 file_offset, 195 virtual_offset, text_end, 196 VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL, 197 MAP_COPY_ON_WRITE | MAP_PREFAULT); 198 if (error) { 199 vm_map_unlock(map); |
201 mtx_unlock(&vm_mtx); | |
202 return (error); 203 } 204 data_end = text_end + a_out->a_data; 205 if (a_out->a_data) { 206 vm_object_reference(object); 207 error = vm_map_insert(map, object, 208 file_offset + a_out->a_text, 209 text_end, data_end, 210 VM_PROT_ALL, VM_PROT_ALL, 211 MAP_COPY_ON_WRITE | MAP_PREFAULT); 212 if (error) { 213 vm_map_unlock(map); | 200 return (error); 201 } 202 data_end = text_end + a_out->a_data; 203 if (a_out->a_data) { 204 vm_object_reference(object); 205 error = vm_map_insert(map, object, 206 file_offset + a_out->a_text, 207 text_end, data_end, 208 VM_PROT_ALL, VM_PROT_ALL, 209 MAP_COPY_ON_WRITE | MAP_PREFAULT); 210 if (error) { 211 vm_map_unlock(map); |
214 mtx_unlock(&vm_mtx); | |
215 return (error); 216 } 217 } 218 219 if (bss_size) { 220 error = vm_map_insert(map, NULL, 0, 221 data_end, data_end + bss_size, 222 VM_PROT_ALL, VM_PROT_ALL, 0); 223 if (error) { 224 vm_map_unlock(map); | 212 return (error); 213 } 214 } 215 216 if (bss_size) { 217 error = vm_map_insert(map, NULL, 0, 218 data_end, data_end + bss_size, 219 VM_PROT_ALL, VM_PROT_ALL, 0); 220 if (error) { 221 vm_map_unlock(map); |
225 mtx_unlock(&vm_mtx); | |
226 return (error); 227 } 228 } 229 vm_map_unlock(map); 230 231 /* Fill in process VM information */ 232 vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT; 233 vmspace->vm_dsize = (a_out->a_data + bss_size) >> PAGE_SHIFT; 234 vmspace->vm_taddr = (caddr_t) (uintptr_t) virtual_offset; 235 vmspace->vm_daddr = (caddr_t) (uintptr_t) 236 (virtual_offset + a_out->a_text); 237 | 222 return (error); 223 } 224 } 225 vm_map_unlock(map); 226 227 /* Fill in process VM information */ 228 vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT; 229 vmspace->vm_dsize = (a_out->a_data + bss_size) >> PAGE_SHIFT; 230 vmspace->vm_taddr = (caddr_t) (uintptr_t) virtual_offset; 231 vmspace->vm_daddr = (caddr_t) (uintptr_t) 232 (virtual_offset + a_out->a_text); 233 |
238 mtx_unlock(&vm_mtx); 239 | |
240 /* Fill in image_params */ 241 imgp->interpreted = 0; 242 imgp->entry_addr = a_out->a_entry; 243 244 imgp->proc->p_sysent = &aout_sysvec; 245 246 /* Indicate that this file should not be modified */ 247 imgp->vp->v_flag |= VTEXT; --- 40 unchanged lines hidden --- | 234 /* Fill in image_params */ 235 imgp->interpreted = 0; 236 imgp->entry_addr = a_out->a_entry; 237 238 imgp->proc->p_sysent = &aout_sysvec; 239 240 /* Indicate that this file should not be modified */ 241 imgp->vp->v_flag |= VTEXT; --- 40 unchanged lines hidden --- |