xref: /illumos-gate/usr/src/lib/crt/i386/crti.s (revision 5e0a5eb7)
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
237c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate * All rights reserved.
257c478bd9Sstevel@tonic-gate */
26a86e931dSRobert Mustacchi/*
27a86e931dSRobert Mustacchi * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
28a86e931dSRobert Mustacchi */
317c478bd9Sstevel@tonic-gate * These crt*.o modules are provided as the bare minimum required
327c478bd9Sstevel@tonic-gate * from a crt*.o for inclusion in building low level system
337c478bd9Sstevel@tonic-gate * libraries.  The are only be to included in libraries which
347c478bd9Sstevel@tonic-gate * contain *no* C++ code and want to avoid the startup code
357c478bd9Sstevel@tonic-gate * that the C++ runtime has introduced into the crt*.o modules.
367c478bd9Sstevel@tonic-gate *
377c478bd9Sstevel@tonic-gate * For further details - see bug#4433015
387c478bd9Sstevel@tonic-gate */
407c478bd9Sstevel@tonic-gate	.file	"crti.s"
41*5e0a5eb7SRichard Lowe	.ident	""
43a86e931dSRobert Mustacchi/*
44ceef08daSJosef 'Jeff' Sipek * Note that when _init and _fini are called the stack needs to be 16-byte
45ceef08daSJosef 'Jeff' Sipek * aligned with a 4-byte bias.  See comment in lib/libc/i386/gen/makectxt.c.
46ceef08daSJosef 'Jeff' Sipek *
47ceef08daSJosef 'Jeff' Sipek * Note: If you change it, you need to change it in the following files as
48ceef08daSJosef 'Jeff' Sipek * well:
49ceef08daSJosef 'Jeff' Sipek *
50ceef08daSJosef 'Jeff' Sipek *  - lib/libc/i386/threads/machdep.c
51ceef08daSJosef 'Jeff' Sipek *  - lib/libc/i386/gen/makectxt.c
523e76f9d6SRichard Lowe *  - lib/crt/i386/mach-crt1.s
53a86e931dSRobert Mustacchi */
54a86e931dSRobert Mustacchi
567c478bd9Sstevel@tonic-gate * _init function prologue
577c478bd9Sstevel@tonic-gate */
587c478bd9Sstevel@tonic-gate	.section	.init,"ax"
597c478bd9Sstevel@tonic-gate	.globl	_init
607c478bd9Sstevel@tonic-gate	.type	_init,@function
617c478bd9Sstevel@tonic-gate	.align	16
637c478bd9Sstevel@tonic-gate	pushl	%ebp
647c478bd9Sstevel@tonic-gate	movl	%esp, %ebp
65a86e931dSRobert Mustacchi	andl	$-16,%esp
66a86e931dSRobert Mustacchi	subl	$12,%esp
677c478bd9Sstevel@tonic-gate	pushl	%ebx
687c478bd9Sstevel@tonic-gate	call	.L1
697c478bd9Sstevel@tonic-gate.L1:	popl	%ebx
707c478bd9Sstevel@tonic-gate	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L1], %ebx
737c478bd9Sstevel@tonic-gate * _fini function prologue
747c478bd9Sstevel@tonic-gate */
757c478bd9Sstevel@tonic-gate	.section	.fini,"ax"
767c478bd9Sstevel@tonic-gate	.globl	_fini
777c478bd9Sstevel@tonic-gate	.type	_fini,@function
787c478bd9Sstevel@tonic-gate	.align	16
807c478bd9Sstevel@tonic-gate	pushl	%ebp
817c478bd9Sstevel@tonic-gate	movl	%esp, %ebp
82a86e931dSRobert Mustacchi	andl	$-16,%esp
83a86e931dSRobert Mustacchi	subl	$12,%esp
847c478bd9Sstevel@tonic-gate	pushl	%ebx
857c478bd9Sstevel@tonic-gate	call	.L2
867c478bd9Sstevel@tonic-gate.L2:	popl	%ebx
877c478bd9Sstevel@tonic-gate	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L2], %ebx