2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <sys/asm_linkage.h>
2N/A#include <brand_misc.h>
2N/A
2N/A#if defined(lint)
2N/A
2N/A/*ARGSUSED*/
2N/Avoid
2N/Abrand_runexe(void *argv, ulong_t entry)
2N/A{
2N/A}
2N/A
2N/A#else /* lint */
2N/A /*
2N/A * Prepare to jump to the target program we actually want to run.
2N/A * If this program is dynamically linked then we'll be jumping to
2N/A * another copy of the linker. If it's a statically linked program
2N/A * we'll be jumping directy to it's main entry point. In any case,
2N/A * we need to reset our current state stack and register state to
2N/A * something similar to the initial process state setup by the kernel
2N/A * and documented at:
2N/A * usr/src/cmd/sgs/rtld/i386/boot.s
2N/A * usr/src/cmd/sgs/rtld/sparcv9/boot.s
2N/A *
2N/A * Of course this is the same stack format as when this executable
2N/A * was first started, so here we'll just roll back the stack and
2N/A * frame pointers to their values when this processes first started
2N/A * execution.
2N/A */
2N/A ENTRY_NP(brand_runexe)
2N/A
2N/A movl 4(%esp), %eax / %eax = &argv[0]
2N/A movl 8(%esp), %ebx / Brand app entry point in %ebx
2N/A subl $4, %eax / Top of stack - must point at argc
2N/A movl %eax, %esp / Set %esp to what linkers expect
2N/A
2N/A /*
2N/A * We also have to make sure to clear %edx since nornally ld.so.1 will
2N/A * set that to non-zero if there is an exit function that should be
2N/A * invoked when the process is terminating. This isn't actually
2N/A * necessary if the target program we're jumping to is a dynamically
2N/A * linked program since in that case we're actually jumping to another
2N/A * copy of ld.so.1 and it will just reset %edx, but if the target
2N/A * program we're jumping to is a statically linked binary that uses
2N/A * the standard sun compiler supplied crt1.o`_start(), it will check
2N/A * to see if %g1 is set.
2N/A */
2N/A movl $0, %edx
2N/A
2N/A jmp *%ebx / And away we go...
2N/A /*
2N/A * target will never return.
2N/A */
2N/A SET_SIZE(brand_runexe)
2N/A#endif /* lint */