1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26#include <sys/asm_linkage.h> 27 28#if defined(lint) 29 30void 31_start(void) 32{ 33} 34 35#else /* lint */ 36 /* 37 * Initial entry point for the brand emulation library. 38 * 39 * This platform specific assembly entry point exists just to invoke 40 * the common brand library startup routine. That routine expects to 41 * be called with the following arguments: 42 * brand_init(int argc, char *argv[], char *envp[]) 43 * 44 * There are no arguments explicitly passed to this entry point, 45 * routine, but we do know how our initial stack has been setup by 46 * the kernel. The stack format is documented in: 47 * usr/src/cmd/sgs/rtld/amd64/boot.s 48 * 49 * So this routine will troll through the stack to setup the argument 50 * values for the common brand library startup routine and then invoke 51 * it. This routine is modeled after the default crt1.s`_start() 52 * routines. 53 */ 54 ENTRY_NP(_start) 55 56 /* Make stack traces look pretty, build a fake stack frame. */ 57 pushq $0 / Build a stack frame. retpc = NULL 58 pushq $0 / fp = NULL 59 movq %rsp, %rbp / first stack frame 60 61 /* 62 * Calculate the location of the envp array by adding the size of 63 * the argv array to the start of the argv array. 64 */ 65 movq 16(%rbp), %rdi / argc in %rax (1st param) 66 leaq 24(%rbp), %rsi / &argv[0] in %rbx (2nd param) 67 leaq 32(%rbp,%rdi,8), %rdx / envp in %rcx (3rd param) 68 call brand_init 69 70 /*NOTREACHED*/ 71 SET_SIZE(_start) 72#endif /* lint */ 73