ia32_sysvec.c (197729) | ia32_sysvec.c (205014) |
---|---|
1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * Copyright (c) 2003 Peter Wemm 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * Copyright (c) 2003 Peter Wemm 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/compat/ia32/ia32_sysvec.c 197729 2009-10-03 11:57:21Z bz $"); | 29__FBSDID("$FreeBSD: head/sys/compat/ia32/ia32_sysvec.c 205014 2010-03-11 14:49:06Z nwhitehorn $"); |
30 31#include "opt_compat.h" 32 33#define __ELF_WORD_SIZE 32 34 35#include <sys/param.h> 36#include <sys/exec.h> 37#include <sys/fcntl.h> --- 50 unchanged lines hidden (view full) --- 88CTASSERT(sizeof(struct ia32_sigframe) == 800); 89CTASSERT(sizeof(struct siginfo32) == 64); 90#ifdef COMPAT_FREEBSD4 91CTASSERT(sizeof(struct ia32_mcontext4) == 260); 92CTASSERT(sizeof(struct ia32_ucontext4) == 324); 93CTASSERT(sizeof(struct ia32_sigframe4) == 408); 94#endif 95 | 30 31#include "opt_compat.h" 32 33#define __ELF_WORD_SIZE 32 34 35#include <sys/param.h> 36#include <sys/exec.h> 37#include <sys/fcntl.h> --- 50 unchanged lines hidden (view full) --- 88CTASSERT(sizeof(struct ia32_sigframe) == 800); 89CTASSERT(sizeof(struct siginfo32) == 64); 90#ifdef COMPAT_FREEBSD4 91CTASSERT(sizeof(struct ia32_mcontext4) == 260); 92CTASSERT(sizeof(struct ia32_ucontext4) == 324); 93CTASSERT(sizeof(struct ia32_sigframe4) == 408); 94#endif 95 |
96static register_t *ia32_copyout_strings(struct image_params *imgp); | |
97static void ia32_fixlimit(struct rlimit *rl, int which); 98 99SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); 100 101static u_long ia32_maxdsiz = IA32_MAXDSIZ; 102SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); 103TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); 104static u_long ia32_maxssiz = IA32_MAXSSIZ; --- 22 unchanged lines hidden (view full) --- 127 .sv_imgact_try = NULL, 128 .sv_minsigstksz = MINSIGSTKSZ, 129 .sv_pagesize = IA32_PAGE_SIZE, 130 .sv_minuser = 0, 131 .sv_maxuser = FREEBSD32_USRSTACK, 132 .sv_usrstack = FREEBSD32_USRSTACK, 133 .sv_psstrings = FREEBSD32_PS_STRINGS, 134 .sv_stackprot = VM_PROT_ALL, | 96static void ia32_fixlimit(struct rlimit *rl, int which); 97 98SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); 99 100static u_long ia32_maxdsiz = IA32_MAXDSIZ; 101SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); 102TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); 103static u_long ia32_maxssiz = IA32_MAXSSIZ; --- 22 unchanged lines hidden (view full) --- 126 .sv_imgact_try = NULL, 127 .sv_minsigstksz = MINSIGSTKSZ, 128 .sv_pagesize = IA32_PAGE_SIZE, 129 .sv_minuser = 0, 130 .sv_maxuser = FREEBSD32_USRSTACK, 131 .sv_usrstack = FREEBSD32_USRSTACK, 132 .sv_psstrings = FREEBSD32_PS_STRINGS, 133 .sv_stackprot = VM_PROT_ALL, |
135 .sv_copyout_strings = ia32_copyout_strings, | 134 .sv_copyout_strings = freebsd32_copyout_strings, |
136 .sv_setregs = ia32_setregs, 137 .sv_fixlimit = ia32_fixlimit, 138 .sv_maxssiz = &ia32_maxssiz, 139 .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 140}; 141 142 143static Elf32_Brandinfo ia32_brand_info = { --- 45 unchanged lines hidden (view full) --- 189 190 191void 192elf32_dump_thread(struct thread *td __unused, void *dst __unused, 193 size_t *off __unused) 194{ 195} 196 | 135 .sv_setregs = ia32_setregs, 136 .sv_fixlimit = ia32_fixlimit, 137 .sv_maxssiz = &ia32_maxssiz, 138 .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 139}; 140 141 142static Elf32_Brandinfo ia32_brand_info = { --- 45 unchanged lines hidden (view full) --- 188 189 190void 191elf32_dump_thread(struct thread *td __unused, void *dst __unused, 192 size_t *off __unused) 193{ 194} 195 |
197 198/* XXX may be freebsd32 MI */ 199static register_t * 200ia32_copyout_strings(struct image_params *imgp) 201{ 202 int argc, envc; 203 u_int32_t *vectp; 204 char *stringp, *destp; 205 u_int32_t *stack_base; 206 struct freebsd32_ps_strings *arginfo; 207 size_t execpath_len; 208 int szsigcode; 209 210 /* 211 * Calculate string base and vector table pointers. 212 * Also deal with signal trampoline code for this exec type. 213 */ 214 if (imgp->execpath != NULL && imgp->auxargs != NULL) 215 execpath_len = strlen(imgp->execpath) + 1; 216 else 217 execpath_len = 0; 218 arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS; 219 szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); 220 destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - 221 roundup(execpath_len, sizeof(char *)) - 222 roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); 223 224 /* 225 * install sigcode 226 */ 227 if (szsigcode) 228 copyout(imgp->proc->p_sysent->sv_sigcode, 229 ((caddr_t)arginfo - szsigcode), szsigcode); 230 231 /* 232 * Copy the image path for the rtld. 233 */ 234 if (execpath_len != 0) { 235 imgp->execpathp = (uintptr_t)arginfo - szsigcode - execpath_len; 236 copyout(imgp->execpath, (void *)imgp->execpathp, 237 execpath_len); 238 } 239 240 /* 241 * If we have a valid auxargs ptr, prepare some room 242 * on the stack. 243 */ 244 if (imgp->auxargs) { 245 /* 246 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for 247 * lower compatibility. 248 */ 249 imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size 250 : (AT_COUNT * 2); 251 /* 252 * The '+ 2' is for the null pointers at the end of each of 253 * the arg and env vector sets,and imgp->auxarg_size is room 254 * for argument of Runtime loader. 255 */ 256 vectp = (u_int32_t *) (destp - (imgp->args->argc + 257 imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) * 258 sizeof(u_int32_t)); 259 } else 260 /* 261 * The '+ 2' is for the null pointers at the end of each of 262 * the arg and env vector sets 263 */ 264 vectp = (u_int32_t *) 265 (destp - (imgp->args->argc + imgp->args->envc + 2) * sizeof(u_int32_t)); 266 267 /* 268 * vectp also becomes our initial stack base 269 */ 270 stack_base = vectp; 271 272 stringp = imgp->args->begin_argv; 273 argc = imgp->args->argc; 274 envc = imgp->args->envc; 275 /* 276 * Copy out strings - arguments and environment. 277 */ 278 copyout(stringp, destp, ARG_MAX - imgp->args->stringspace); 279 280 /* 281 * Fill in "ps_strings" struct for ps, w, etc. 282 */ 283 suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp); 284 suword32(&arginfo->ps_nargvstr, argc); 285 286 /* 287 * Fill in argument portion of vector table. 288 */ 289 for (; argc > 0; --argc) { 290 suword32(vectp++, (u_int32_t)(intptr_t)destp); 291 while (*stringp++ != 0) 292 destp++; 293 destp++; 294 } 295 296 /* a null vector table pointer separates the argp's from the envp's */ 297 suword32(vectp++, 0); 298 299 suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp); 300 suword32(&arginfo->ps_nenvstr, envc); 301 302 /* 303 * Fill in environment portion of vector table. 304 */ 305 for (; envc > 0; --envc) { 306 suword32(vectp++, (u_int32_t)(intptr_t)destp); 307 while (*stringp++ != 0) 308 destp++; 309 destp++; 310 } 311 312 /* end of vector table is a null pointer */ 313 suword32(vectp, 0); 314 315 return ((register_t *)stack_base); 316} 317 | |
318static void 319ia32_fixlimit(struct rlimit *rl, int which) 320{ 321 322 switch (which) { 323 case RLIMIT_DATA: 324 if (ia32_maxdsiz != 0) { 325 if (rl->rlim_cur > ia32_maxdsiz) --- 23 unchanged lines hidden --- | 196static void 197ia32_fixlimit(struct rlimit *rl, int which) 198{ 199 200 switch (which) { 201 case RLIMIT_DATA: 202 if (ia32_maxdsiz != 0) { 203 if (rl->rlim_cur > ia32_maxdsiz) --- 23 unchanged lines hidden --- |