Home | History | Annotate | Line # | Download | only in common
      1 /*	$NetBSD: linux32_exec.c,v 1.24 2018/08/10 21:44:58 pgoyette Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1994-2007 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz,
      9  * Thor Lancelot Simon, and Emmanuel Dreyfus.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include <sys/cdefs.h>
     34 __KERNEL_RCSID(0, "$NetBSD: linux32_exec.c,v 1.24 2018/08/10 21:44:58 pgoyette Exp $");
     35 
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 #include <sys/kernel.h>
     39 #include <sys/proc.h>
     40 #include <sys/exec.h>
     41 #include <sys/exec_elf.h>
     42 
     43 #include <sys/mman.h>
     44 #include <sys/syscallargs.h>
     45 
     46 #include <compat/linux/common/linux_types.h>
     47 #include <compat/linux/common/linux_exec.h>
     48 
     49 #include <compat/linux32/common/linux32_exec.h>
     50 #include <compat/linux32/common/linux32_types.h>
     51 #include <compat/linux32/common/linux32_signal.h>
     52 #include <compat/linux32/common/linux32_machdep.h>
     53 
     54 #include <compat/linux32/linux32_syscallargs.h>
     55 #include <compat/linux32/linux32_syscall.h>
     56 
     57 extern struct sysent linux32_sysent[];
     58 extern const uint32_t linux32_sysent_nomodbits[];
     59 extern const char * const linux32_syscallnames[];
     60 extern char linux32_sigcode[], linux32_esigcode[];
     61 
     62 /*
     63  * Emulation switch.
     64  */
     65 
     66 struct uvm_object *emul_linux32_object;
     67 
     68 struct emul emul_linux32 = {
     69 	.e_name =		"linux32",
     70 	.e_path =		"/emul/linux32",
     71 #ifndef __HAVE_MINIMAL_EMUL
     72 	.e_flags =		0,
     73 	.e_errno =		NULL,
     74 	.e_nosys =		LINUX32_SYS_syscall,
     75 	.e_nsysent =		LINUX32_SYS_NSYSENT,
     76 #endif
     77 	.e_sysent =		linux32_sysent,
     78 	.e_nomodbits =		linux32_sysent_nomodbits,
     79 	.e_syscallnames =	linux32_syscallnames,
     80 	.e_sendsig =		linux32_sendsig,
     81 	.e_trapsignal =		linux_trapsignal,
     82 	.e_sigcode =		linux32_sigcode,
     83 	.e_esigcode =		linux32_esigcode,
     84 	.e_sigobject =		&emul_linux32_object,
     85 	.e_setregs =		linux32_setregs,
     86 	.e_proc_exec =		linux_e_proc_exec,
     87 	.e_proc_fork =		linux_e_proc_fork,
     88 	.e_proc_exit =		linux_e_proc_exit,
     89 	.e_lwp_fork =		linux_e_lwp_fork,
     90 	.e_lwp_exit =		linux_e_lwp_exit,
     91 	.e_syscall_intern =	linux32_syscall_intern,
     92 	.e_sysctlovly =		NULL,
     93 	.e_vm_default_addr =	netbsd32_vm_default_addr,
     94 	.e_usertrap =		NULL,
     95 	.e_ucsize =		0,
     96 	.e_startlwp =		NULL
     97 };
     98