static void  
exec_setregs_funcdesc(struct thread *td, struct image_params *imgp,
    u_long stack)
{
	struct trapframe *tf;
	register_t entry_desc[3];

	tf = trapframe(td);
	exec_setregs(td, imgp, stack);

	/*
	 * For 64-bit ELFv1, we need to disentangle the function
	 * descriptor
	 *
	 * 0. entry point
	 * 1. TOC value (r2)
	 * 2. Environment pointer (r11)
	 */

	(void)copyin((void *)imgp->entry_addr, entry_desc,
	    sizeof(entry_desc));
	tf->srr0 = entry_desc[0] + imgp->reloc_base;
	tf->fixreg[2] = entry_desc[1] + imgp->reloc_base;
	tf->fixreg[11] = entry_desc[2] + imgp->reloc_base;
}
Example #2
0
/*
 * exec_setregs may initialize some registers differently than Linux
 * does, thus potentially confusing Linux binaries. If necessary, we
 * override the exec_setregs default(s) here.
 */
static void
exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
{
	struct pcb *pcb = td->td_pcb;

	exec_setregs(td, imgp, stack);

	/* Linux sets %gs to 0, we default to _udatasel */
	pcb->pcb_gs = 0;
	load_gs(0);

	pcb->pcb_initial_npxcw = __LINUX_NPXCW__;
}
Example #3
0
static void
freebsd32_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
{
	exec_setregs(td, imgp, stack);

	/*
	 * See comment in exec_setregs about running 32-bit binaries with 64-bit
	 * registers.
	 */
	td->td_frame->sp -= 65536;

	/*
	 * Clear extended address space bit for userland.
	 */
	td->td_frame->sr &= ~MIPS_SR_UX;
}
Example #4
0
static void
cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
                        unsigned long stack)
{
    struct trapframe *regs;

    exec_setregs(td, imgp, stack);

    /*
     * The stack now contains a pointer to the TCB and the auxiliary
     * vector. Let x0 point to the auxiliary vector, and set
     * tpidr_el0 to the TCB.
     */
    regs = td->td_frame;
    regs->tf_x[0] = td->td_retval[0] =
                        stack + roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
    (void)cpu_set_user_tls(td, (void *)stack);
}