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/i386/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 pushl $0 / retpc = NULL 58 pushl $0 / fp = NULL 59 movl %esp, %ebp / 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 movl 8(%ebp), %eax / argc in %eax 66 leal 12(%ebp), %ebx / &argv[0] in %ebx 67 leal 16(%ebp,%eax,4), %ecx / envp in %ecx 68 69 pushl %ecx / push envp (3rd param) 70 pushl %ebx / push argv (2nd param) 71 pushl %eax / push argc (1st param) 72 call brand_init 73 74 /*NOTREACHED*/ 75 SET_SIZE(_start) 76#endif /* lint */ 77