xref: /titanic_51/usr/src/lib/crt/i386/crti.s (revision 3e0c804466b61d42dc6a3e1cb114c11681ef181a)
1*3e0c8044SRichard Lowe/*
2*3e0c8044SRichard Lowe * CDDL HEADER START
3*3e0c8044SRichard Lowe *
4*3e0c8044SRichard Lowe * The contents of this file are subject to the terms of the
5*3e0c8044SRichard Lowe * Common Development and Distribution License, Version 1.0 only
6*3e0c8044SRichard Lowe * (the "License").  You may not use this file except in compliance
7*3e0c8044SRichard Lowe * with the License.
8*3e0c8044SRichard Lowe *
9*3e0c8044SRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*3e0c8044SRichard Lowe * or http://www.opensolaris.org/os/licensing.
11*3e0c8044SRichard Lowe * See the License for the specific language governing permissions
12*3e0c8044SRichard Lowe * and limitations under the License.
13*3e0c8044SRichard Lowe *
14*3e0c8044SRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each
15*3e0c8044SRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*3e0c8044SRichard Lowe * If applicable, add the following below this CDDL HEADER, with the
17*3e0c8044SRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
18*3e0c8044SRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
19*3e0c8044SRichard Lowe *
20*3e0c8044SRichard Lowe * CDDL HEADER END
21*3e0c8044SRichard Lowe */
22*3e0c8044SRichard Lowe/*
23*3e0c8044SRichard Lowe * Copyright (c) 2001 by Sun Microsystems, Inc.
24*3e0c8044SRichard Lowe * All rights reserved.
25*3e0c8044SRichard Lowe */
26*3e0c8044SRichard Lowe/*
27*3e0c8044SRichard Lowe * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
28*3e0c8044SRichard Lowe */
29*3e0c8044SRichard Lowe
30*3e0c8044SRichard Lowe/*
31*3e0c8044SRichard Lowe * These crt*.o modules are provided as the bare minimum required
32*3e0c8044SRichard Lowe * from a crt*.o for inclusion in building low level system
33*3e0c8044SRichard Lowe * libraries.  The are only be to included in libraries which
34*3e0c8044SRichard Lowe * contain *no* C++ code and want to avoid the startup code
35*3e0c8044SRichard Lowe * that the C++ runtime has introduced into the crt*.o modules.
36*3e0c8044SRichard Lowe *
37*3e0c8044SRichard Lowe * For further details - see bug#4433015
38*3e0c8044SRichard Lowe */
39*3e0c8044SRichard Lowe
40*3e0c8044SRichard Lowe	.file	"crti.s"
41*3e0c8044SRichard Lowe
42*3e0c8044SRichard Lowe/*
43*3e0c8044SRichard Lowe * Note that when _init and _fini are called the stack needs to be 16-byte
44*3e0c8044SRichard Lowe * aligned with a 4-byte bias.  See comment in lib/libc/i386/gen/makectxt.c.
45*3e0c8044SRichard Lowe *
46*3e0c8044SRichard Lowe * Note: If you change it, you need to change it in the following files as
47*3e0c8044SRichard Lowe * well:
48*3e0c8044SRichard Lowe *
49*3e0c8044SRichard Lowe *  - lib/libc/i386/threads/machdep.c
50*3e0c8044SRichard Lowe *  - lib/libc/i386/gen/makectxt.c
51*3e0c8044SRichard Lowe *  - lib/crt/i386/mach-crt1.s
52*3e0c8044SRichard Lowe */
53*3e0c8044SRichard Lowe
54*3e0c8044SRichard Lowe/*
55*3e0c8044SRichard Lowe * _init function prologue
56*3e0c8044SRichard Lowe */
57*3e0c8044SRichard Lowe	.section	.init,"ax"
58*3e0c8044SRichard Lowe	.globl	_init
59*3e0c8044SRichard Lowe	.type	_init,@function
60*3e0c8044SRichard Lowe	.align	16
61*3e0c8044SRichard Lowe_init:
62*3e0c8044SRichard Lowe	pushl	%ebp
63*3e0c8044SRichard Lowe	movl	%esp, %ebp
64*3e0c8044SRichard Lowe	andl	$-16,%esp
65*3e0c8044SRichard Lowe	subl	$12,%esp
66*3e0c8044SRichard Lowe	pushl	%ebx
67*3e0c8044SRichard Lowe	call	.L1
68*3e0c8044SRichard Lowe.L1:	popl	%ebx
69*3e0c8044SRichard Lowe	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L1], %ebx
70*3e0c8044SRichard Lowe
71*3e0c8044SRichard Lowe/*
72*3e0c8044SRichard Lowe * _fini function prologue
73*3e0c8044SRichard Lowe */
74*3e0c8044SRichard Lowe	.section	.fini,"ax"
75*3e0c8044SRichard Lowe	.globl	_fini
76*3e0c8044SRichard Lowe	.type	_fini,@function
77*3e0c8044SRichard Lowe	.align	16
78*3e0c8044SRichard Lowe_fini:
79*3e0c8044SRichard Lowe	pushl	%ebp
80*3e0c8044SRichard Lowe	movl	%esp, %ebp
81*3e0c8044SRichard Lowe	andl	$-16,%esp
82*3e0c8044SRichard Lowe	subl	$12,%esp
83*3e0c8044SRichard Lowe	pushl	%ebx
84*3e0c8044SRichard Lowe	call	.L2
85*3e0c8044SRichard Lowe.L2:	popl	%ebx
86*3e0c8044SRichard Lowe	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L2], %ebx
87