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