1# crti.s for sysv4
2
3#   Copyright (C) 1996 Free Software Foundation, Inc.
4#   Written By Michael Meissner
5# 
6# This file is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any
9# later version.
10# 
11# In addition to the permissions in the GNU General Public License, the
12# Free Software Foundation gives you unlimited permission to link the
13# compiled version of this file with other programs, and to distribute
14# those programs without any restriction coming from the use of this
15# file.  (The General Public License restrictions do apply in other
16# respects; for example, they cover modification of the file, and
17# distribution when not linked into another program.)
18# 
19# This file is distributed in the hope that it will be useful, but
20# WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22# General Public License for more details.
23# 
24# You should have received a copy of the GNU General Public License
25# along with this program; see the file COPYING.  If not, write to
26# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27# Boston, MA 02110-1301, USA.
28# 
29#    As a special exception, if you link this library with files
30#    compiled with GCC to produce an executable, this does not cause
31#    the resulting executable to be covered by the GNU General Public License.
32#    This exception does not however invalidate any other reasons why
33#    the executable file might be covered by the GNU General Public License.
34# 
35
36# This file just supplies labeled starting points for the .got* and other
37# special sections.  It is linked in first before other modules.
38 
39	.file	"scrti.s"
40	.ident	"GNU C scrti.s"
41
42#ifndef __powerpc64__
43# Start of .text
44	.section ".text"
45	.globl	_ex_text0
46_ex_text0:
47
48# Exception range
49	.section ".exception_ranges","aw"
50	.globl	_ex_range0
51_ex_range0:
52
53# List of C++ constructors
54	.section ".ctors","aw"
55	.globl	__CTOR_LIST__
56	.type	__CTOR_LIST__,@object
57__CTOR_LIST__:
58
59# List of C++ destructors
60	.section ".dtors","aw"
61	.globl	__DTOR_LIST__
62	.type	__DTOR_LIST__,@object
63__DTOR_LIST__:
64
65# Head of _init function used for static constructors
66	.section ".init","ax"
67	.align 2
68	.globl _init
69	.type _init,@function
70_init:	stwu	%r1,-16(%r1)
71	mflr	%r0
72	stw	%r31,12(%r1)
73	stw	%r0,16(%r1)
74
75	bl	_GLOBAL_OFFSET_TABLE_-4	# get the GOT address
76	mflr	%r31
77
78#	lwz	%r3,_ex_shared0@got(%r31)
79#	lwz	%r4,-8(%r3)		# _ex_register or 0
80#	cmpi	%cr0,%r4,0
81#	beq	.Lno_reg
82#	mtlr	%r4
83#	blrl
84#.Lno_reg:
85
86# Head of _fini function used for static destructors
87	.section ".fini","ax"
88	.align 2
89	.globl _fini
90	.type _fini,@function
91_fini:	stwu	%r1,-16(%r1)
92	mflr	%r0
93	stw	%r31,12(%r1)
94	stw	%r0,16(%r1)
95
96	bl	_GLOBAL_OFFSET_TABLE_-4	# get the GOT address
97	mflr	%r31
98
99# _environ and its evil twin environ, pointing to the environment
100	.section ".sdata","aw"
101	.align 2
102	.globl _environ
103	.space 4
104	.weak	environ
105	.set	environ,_environ
106#endif
107