xref: /illumos-gate/usr/src/lib/crt/i386/crti.s (revision 3e76f9d6)
17c478bd9Sstevel@tonic-gate/*
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 */
227c478bd9Sstevel@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 */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate/*
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 */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate	.file	"crti.s"
417c478bd9Sstevel@tonic-gate
42a86e931dSRobert Mustacchi/*
43ceef08daSJosef 'Jeff' Sipek * Note that when _init and _fini are called the stack needs to be 16-byte
44ceef08daSJosef 'Jeff' Sipek * aligned with a 4-byte bias.  See comment in lib/libc/i386/gen/makectxt.c.
45ceef08daSJosef 'Jeff' Sipek *
46ceef08daSJosef 'Jeff' Sipek * Note: If you change it, you need to change it in the following files as
47ceef08daSJosef 'Jeff' Sipek * well:
48ceef08daSJosef 'Jeff' Sipek *
49ceef08daSJosef 'Jeff' Sipek *  - lib/libc/i386/threads/machdep.c
50ceef08daSJosef 'Jeff' Sipek *  - lib/libc/i386/gen/makectxt.c
51*3e76f9d6SRichard Lowe *  - lib/crt/i386/mach-crt1.s
52a86e931dSRobert Mustacchi */
53a86e931dSRobert Mustacchi
547c478bd9Sstevel@tonic-gate/*
557c478bd9Sstevel@tonic-gate * _init function prologue
567c478bd9Sstevel@tonic-gate */
577c478bd9Sstevel@tonic-gate	.section	.init,"ax"
587c478bd9Sstevel@tonic-gate	.globl	_init
597c478bd9Sstevel@tonic-gate	.type	_init,@function
607c478bd9Sstevel@tonic-gate	.align	16
617c478bd9Sstevel@tonic-gate_init:
627c478bd9Sstevel@tonic-gate	pushl	%ebp
637c478bd9Sstevel@tonic-gate	movl	%esp, %ebp
64a86e931dSRobert Mustacchi	andl	$-16,%esp
65a86e931dSRobert Mustacchi	subl	$12,%esp
667c478bd9Sstevel@tonic-gate	pushl	%ebx
677c478bd9Sstevel@tonic-gate	call	.L1
687c478bd9Sstevel@tonic-gate.L1:	popl	%ebx
697c478bd9Sstevel@tonic-gate	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L1], %ebx
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate/*
727c478bd9Sstevel@tonic-gate * _fini function prologue
737c478bd9Sstevel@tonic-gate */
747c478bd9Sstevel@tonic-gate	.section	.fini,"ax"
757c478bd9Sstevel@tonic-gate	.globl	_fini
767c478bd9Sstevel@tonic-gate	.type	_fini,@function
777c478bd9Sstevel@tonic-gate	.align	16
787c478bd9Sstevel@tonic-gate_fini:
797c478bd9Sstevel@tonic-gate	pushl	%ebp
807c478bd9Sstevel@tonic-gate	movl	%esp, %ebp
81a86e931dSRobert Mustacchi	andl	$-16,%esp
82a86e931dSRobert Mustacchi	subl	$12,%esp
837c478bd9Sstevel@tonic-gate	pushl	%ebx
847c478bd9Sstevel@tonic-gate	call	.L2
857c478bd9Sstevel@tonic-gate.L2:	popl	%ebx
867c478bd9Sstevel@tonic-gate	addl	$_GLOBAL_OFFSET_TABLE_+[.-.L2], %ebx
87