190075Sobrien# crti.s for sysv4
290075Sobrien
390075Sobrien#   Copyright (C) 1996 Free Software Foundation, Inc.
490075Sobrien#   Written By Michael Meissner
590075Sobrien# 
690075Sobrien# This file is free software; you can redistribute it and/or modify it
790075Sobrien# under the terms of the GNU General Public License as published by the
890075Sobrien# Free Software Foundation; either version 2, or (at your option) any
990075Sobrien# later version.
1090075Sobrien# 
1190075Sobrien# In addition to the permissions in the GNU General Public License, the
1290075Sobrien# Free Software Foundation gives you unlimited permission to link the
1390075Sobrien# compiled version of this file with other programs, and to distribute
1490075Sobrien# those programs without any restriction coming from the use of this
1590075Sobrien# file.  (The General Public License restrictions do apply in other
1690075Sobrien# respects; for example, they cover modification of the file, and
1790075Sobrien# distribution when not linked into another program.)
1890075Sobrien# 
1990075Sobrien# This file is distributed in the hope that it will be useful, but
2090075Sobrien# WITHOUT ANY WARRANTY; without even the implied warranty of
2190075Sobrien# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2290075Sobrien# General Public License for more details.
2390075Sobrien# 
2490075Sobrien# You should have received a copy of the GNU General Public License
2590075Sobrien# along with this program; see the file COPYING.  If not, write to
26169689Skan# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27169689Skan# Boston, MA 02110-1301, USA.
2890075Sobrien# 
2990075Sobrien#    As a special exception, if you link this library with files
3090075Sobrien#    compiled with GCC to produce an executable, this does not cause
3190075Sobrien#    the resulting executable to be covered by the GNU General Public License.
3290075Sobrien#    This exception does not however invalidate any other reasons why
3390075Sobrien#    the executable file might be covered by the GNU General Public License.
3490075Sobrien# 
3590075Sobrien
3690075Sobrien# This file just supplies labeled starting points for the .got* and other
3790075Sobrien# special sections.  It is linked in first before other modules.
3890075Sobrien 
3990075Sobrien	.file	"scrti.s"
4090075Sobrien	.ident	"GNU C scrti.s"
4190075Sobrien
42132718Skan#ifndef __powerpc64__
4390075Sobrien# Start of .text
4490075Sobrien	.section ".text"
4590075Sobrien	.globl	_ex_text0
4690075Sobrien_ex_text0:
4790075Sobrien
4890075Sobrien# Exception range
4990075Sobrien	.section ".exception_ranges","aw"
5090075Sobrien	.globl	_ex_range0
5190075Sobrien_ex_range0:
5290075Sobrien
5390075Sobrien# List of C++ constructors
5490075Sobrien	.section ".ctors","aw"
5590075Sobrien	.globl	__CTOR_LIST__
5690075Sobrien	.type	__CTOR_LIST__,@object
5790075Sobrien__CTOR_LIST__:
5890075Sobrien
5990075Sobrien# List of C++ destructors
6090075Sobrien	.section ".dtors","aw"
6190075Sobrien	.globl	__DTOR_LIST__
6290075Sobrien	.type	__DTOR_LIST__,@object
6390075Sobrien__DTOR_LIST__:
6490075Sobrien
6590075Sobrien# Head of _init function used for static constructors
6690075Sobrien	.section ".init","ax"
6790075Sobrien	.align 2
6890075Sobrien	.globl _init
6990075Sobrien	.type _init,@function
7090075Sobrien_init:	stwu	%r1,-16(%r1)
7190075Sobrien	mflr	%r0
7290075Sobrien	stw	%r31,12(%r1)
7390075Sobrien	stw	%r0,16(%r1)
7490075Sobrien
7590075Sobrien	bl	_GLOBAL_OFFSET_TABLE_-4	# get the GOT address
7690075Sobrien	mflr	%r31
7790075Sobrien
7890075Sobrien#	lwz	%r3,_ex_shared0@got(%r31)
7990075Sobrien#	lwz	%r4,-8(%r3)		# _ex_register or 0
8090075Sobrien#	cmpi	%cr0,%r4,0
8190075Sobrien#	beq	.Lno_reg
8290075Sobrien#	mtlr	%r4
8390075Sobrien#	blrl
8490075Sobrien#.Lno_reg:
8590075Sobrien
8690075Sobrien# Head of _fini function used for static destructors
8790075Sobrien	.section ".fini","ax"
8890075Sobrien	.align 2
8990075Sobrien	.globl _fini
9090075Sobrien	.type _fini,@function
9190075Sobrien_fini:	stwu	%r1,-16(%r1)
9290075Sobrien	mflr	%r0
9390075Sobrien	stw	%r31,12(%r1)
9490075Sobrien	stw	%r0,16(%r1)
9590075Sobrien
9690075Sobrien	bl	_GLOBAL_OFFSET_TABLE_-4	# get the GOT address
9790075Sobrien	mflr	%r31
9890075Sobrien
9990075Sobrien# _environ and its evil twin environ, pointing to the environment
10090075Sobrien	.section ".sdata","aw"
10190075Sobrien	.align 2
10290075Sobrien	.globl _environ
10390075Sobrien	.space 4
10490075Sobrien	.weak	environ
10590075Sobrien	.set	environ,_environ
106132718Skan#endif
107