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
2N/A#if defined(lint)
2N/A
2N/Avoid
2N/A_start(void)
2N/A{
2N/A}
2N/A
2N/A#else /* lint */
2N/A /*
2N/A * Initial entry point for the brand emulation library.
2N/A *
2N/A * This platform specific assembly entry point exists just to invoke
2N/A * the common brand library startup routine. That routine expects to
2N/A * be called with the following arguments:
2N/A * brand_init(int argc, char *argv[], char *envp[])
2N/A *
2N/A * There are no arguments explicitly passed to this entry point,
2N/A * routine, but we do know how our initial stack has been setup by
2N/A * the kernel. The stack format is documented in:
2N/A * usr/src/cmd/sgs/rtld/amd64/boot.s
2N/A *
2N/A * So this routine will troll through the stack to setup the argument
2N/A * values for the common brand library startup routine and then invoke
2N/A * it. This routine is modeled after the default crt1.s`_start()
2N/A * routines.
2N/A */
2N/A ENTRY_NP(_start)
2N/A
2N/A /* Make stack traces look pretty, build a fake stack frame. */
2N/A pushq $0 / Build a stack frame. retpc = NULL
2N/A pushq $0 / fp = NULL
2N/A movq %rsp, %rbp / first stack frame
2N/A
2N/A /*
2N/A * Calculate the location of the envp array by adding the size of
2N/A * the argv array to the start of the argv array.
2N/A */
2N/A movq 16(%rbp), %rdi / argc in %rax (1st param)
2N/A leaq 24(%rbp), %rsi / &argv[0] in %rbx (2nd param)
2N/A leaq 32(%rbp,%rdi,8), %rdx / envp in %rcx (3rd param)
2N/A call brand_init
2N/A
2N/A /*NOTREACHED*/
2N/A SET_SIZE(_start)
2N/A#endif /* lint */