Changeset View
Changeset View
Standalone View
Standalone View
head/sys/i386/linux/linux_sysvec.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
#include <compat/linux/linux_mib.h> | #include <compat/linux/linux_mib.h> | ||||
#include <compat/linux/linux_misc.h> | #include <compat/linux/linux_misc.h> | ||||
#include <compat/linux/linux_signal.h> | #include <compat/linux/linux_signal.h> | ||||
#include <compat/linux/linux_util.h> | #include <compat/linux/linux_util.h> | ||||
#include <compat/linux/linux_vdso.h> | #include <compat/linux/linux_vdso.h> | ||||
MODULE_VERSION(linux, 1); | MODULE_VERSION(linux, 1); | ||||
#if BYTE_ORDER == LITTLE_ENDIAN | |||||
#define SHELLMAGIC 0x2123 /* #! */ | |||||
#else | |||||
#define SHELLMAGIC 0x2321 | |||||
#endif | |||||
#if defined(DEBUG) | #if defined(DEBUG) | ||||
SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, | SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, | ||||
linux_sysctl_debug, "A", "Linux debugging control"); | linux_sysctl_debug, "A", "Linux debugging control"); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Allow the sendsig functions to use the ldebug() facility even though they | * Allow the sendsig functions to use the ldebug() facility even though they | ||||
* are not syscalls themselves. Map them to syscall 0. This is slightly less | * are not syscalls themselves. Map them to syscall 0. This is slightly less | ||||
Show All 14 Lines | |||||
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); | SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); | ||||
static int linux_fixup(register_t **stack_base, | static int linux_fixup(register_t **stack_base, | ||||
struct image_params *iparams); | struct image_params *iparams); | ||||
static int linux_fixup_elf(register_t **stack_base, | static int linux_fixup_elf(register_t **stack_base, | ||||
struct image_params *iparams); | struct image_params *iparams); | ||||
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); | static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); | ||||
static int linux_exec_imgact_try(struct image_params *iparams); | |||||
static void linux_exec_setregs(struct thread *td, | static void linux_exec_setregs(struct thread *td, | ||||
struct image_params *imgp, u_long stack); | struct image_params *imgp, u_long stack); | ||||
static register_t *linux_copyout_strings(struct image_params *imgp); | static register_t *linux_copyout_strings(struct image_params *imgp); | ||||
static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); | static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); | ||||
static void linux_vdso_install(void *param); | static void linux_vdso_install(void *param); | ||||
static void linux_vdso_deinstall(void *param); | static void linux_vdso_deinstall(void *param); | ||||
static int linux_szplatform; | static int linux_szplatform; | ||||
▲ Show 20 Lines • Show All 683 Lines • ▼ Show 20 Lines | linux_fetch_syscall_args(struct thread *td) | ||||
else | else | ||||
sa->callp = &p->p_sysent->sv_table[sa->code]; | sa->callp = &p->p_sysent->sv_table[sa->code]; | ||||
sa->narg = sa->callp->sy_narg; | sa->narg = sa->callp->sy_narg; | ||||
td->td_retval[0] = 0; | td->td_retval[0] = 0; | ||||
td->td_retval[1] = frame->tf_edx; | td->td_retval[1] = frame->tf_edx; | ||||
return (0); | return (0); | ||||
} | |||||
/* | |||||
* If a Linux binary is exec'ing something, try this image activator | |||||
* first. We override standard shell script execution in order to | |||||
* be able to modify the interpreter path. We only do this if a Linux | |||||
* binary is doing the exec, so we do not create an EXEC module for it. | |||||
*/ | |||||
static int | |||||
linux_exec_imgact_try(struct image_params *imgp) | |||||
{ | |||||
const char *head = (const char *)imgp->image_header; | |||||
char *rpath; | |||||
int error = -1; | |||||
/* | |||||
* The interpreter for shell scripts run from a Linux binary needs | |||||
* to be located in /compat/linux if possible in order to recursively | |||||
* maintain Linux path emulation. | |||||
*/ | |||||
if (((const short *)head)[0] == SHELLMAGIC) { | |||||
/* | |||||
* Run our normal shell image activator. If it succeeds then | |||||
* attempt to use the alternate path for the interpreter. If | |||||
* an alternate path is found, use our stringspace to store it. | |||||
*/ | |||||
if ((error = exec_shell_imgact(imgp)) == 0) { | |||||
linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc), | |||||
imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0, | |||||
AT_FDCWD); | |||||
if (rpath != NULL) | |||||
imgp->args->fname_buf = | |||||
imgp->interpreter_name = rpath; | |||||
} | |||||
} | |||||
return (error); | |||||
} | } | ||||
/* | /* | ||||
* exec_setregs may initialize some registers differently than Linux | * exec_setregs may initialize some registers differently than Linux | ||||
* does, thus potentially confusing Linux binaries. If necessary, we | * does, thus potentially confusing Linux binaries. If necessary, we | ||||
* override the exec_setregs default(s) here. | * override the exec_setregs default(s) here. | ||||
*/ | */ | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |