• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *  * Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 *  * Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *    the documentation and/or other materials provided with the
13 *    distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28	.text
29	.align 4
30	.type __start,@function
31	.globl __start
32	.globl _start
33
34# this is the small startup code that is first run when
35# any executable that is statically-linked with Bionic
36# runs.
37#
38# it's purpose is to call __libc_init with appropriate
39# arguments, which are:
40#
41#    - the address of the raw data block setup by the Linux
42#      kernel ELF loader
43#
44#    - address of an "onexit" function, not used on any
45#      platform supported by Bionic
46#
47#    - address of the "main" function of the program.
48#
49#    - address of the constructor list
50#
51
52	.ent	__start
53__start:
54_start:
55	bal	1f
561:
57	.set	noreorder
58	.cpload	$ra
59	.set	reorder
60
61	move	$a0, $sp
62	move	$a1, $0
63	la	$a2, main
64	la	$a3, 1f
65	subu	$sp, 32
66	la	$t9, __libc_init
67	j	$t9
68	.end	__start
69
701:	.long	__PREINIT_ARRAY__
71	.long	__INIT_ARRAY__
72	.long	__FINI_ARRAY__
73	.long	__CTOR_LIST__
74	.long	__DTOR_LIST__
75
76	.section .preinit_array, "aw"
77	.type __PREINIT_ARRAY__, @object
78	.globl __PREINIT_ARRAY__
79__PREINIT_ARRAY__:
80	.long -1
81
82	.section .init_array, "aw"
83	.type __INIT_ARRAY__, @object
84	.globl __INIT_ARRAY__
85__INIT_ARRAY__:
86	.long -1
87	.long frame_dummy
88
89	.section .fini_array, "aw"
90	.type __FINI_ARRAY__, @object
91	.globl __FINI_ARRAY__
92__FINI_ARRAY__:
93	.long -1
94	.long __do_global_dtors_aux
95
96	.section .ctors, "aw"
97	.type __CTOR_LIST__, @object
98	.globl __CTOR_LIST__
99__CTOR_LIST__:
100	.long -1
101
102	.section .dtors, "aw"
103	.type __DTOR_LIST__, @object
104	.globl __DTOR_LIST__
105__DTOR_LIST__:
106	.long -1
107
108	.abicalls
109	.section	.eh_frame,"a",@progbits
110	.align	2
111	.type	__EH_FRAME_BEGIN__, @object
112	.size	__EH_FRAME_BEGIN__, 0
113__EH_FRAME_BEGIN__:
114	.text
115	.align	2
116	.set	nomips16
117	.ent	frame_dummy
118	.type	frame_dummy, @function
119frame_dummy:
120	.frame	$sp,32,$31		# vars= 0, regs= 1/0, args= 16, gp= 8
121	.mask	0x80000000,-4
122	.fmask	0x00000000,0
123	.set	noreorder
124	.cpload	$25
125	.set	nomacro
126	addiu	$sp,$sp,-32
127	sw	$31,28($sp)
128	.cprestore	16
129	lw	$2,%got(__register_frame_info)($28)
130	beq	$2,$0,$L1
131	nop
132
133	lw	$2,%got(__EH_FRAME_BEGIN__)($28)
134	addiu	$4,$2,%lo(__EH_FRAME_BEGIN__)
135	lw	$2,%got(object.1265)($28)
136	addiu	$5,$2,%lo(object.1265)
137	lw	$2,%call16(__register_frame_info)($28)
138	move	$25,$2
139	.reloc	1f,R_MIPS_JALR,__register_frame_info
1401:	jalr	$25
141	nop
142
143	lw	$28,16($sp)
144$L1:
145	lw	$31,28($sp)
146	addiu	$sp,$sp,32
147	j	$31
148	nop
149
150	.text
151	.set	macro
152	.set	reorder
153	.end	frame_dummy
154	.size	frame_dummy, .-frame_dummy
155	.align	2
156	.set	nomips16
157	.ent	__do_global_dtors_aux
158	.type	__do_global_dtors_aux, @function
159__do_global_dtors_aux:
160	.frame	$sp,32,$31		# vars= 0, regs= 1/0, args= 16, gp= 8
161	.mask	0x80000000,-4
162	.fmask	0x00000000,0
163	.set	noreorder
164	.cpload	$25
165	.set	nomacro
166	addiu	$sp,$sp,-32
167	sw	$31,28($sp)
168	.cprestore	16
169	lw	$2,%got(completed.1269)($28)
170	lbu	$2,%lo(completed.1269)($2)
171	bne	$2,$0,$L8
172	nop
173
174$L4:
175	lw	$2,%got(__cxa_finalize)($28)
176	beq	$2,$0,$L6
177	nop
178
179	lw	$2,%got(__dso_handle)($28)
180	lw	$2,0($2)
181	move	$4,$2
182	lw	$2,%call16(__cxa_finalize)($28)
183	move	$25,$2
184	.reloc	1f,R_MIPS_JALR,__cxa_finalize
1851:	jalr	$25
186	nop
187
188	lw	$28,16($sp)
189$L6:
190	lw	$2,%got(__deregister_frame_info)($28)
191	beq	$2,$0,$L7
192	nop
193
194	lw	$2,%got(__EH_FRAME_BEGIN__)($28)
195	addiu	$4,$2,%lo(__EH_FRAME_BEGIN__)
196	lw	$2,%call16(__deregister_frame_info)($28)
197	move	$25,$2
198	.reloc	1f,R_MIPS_JALR,__deregister_frame_info
1991:	jalr	$25
200	nop
201
202	lw	$28,16($sp)
203$L7:
204	lw	$2,%got(completed.1269)($28)
205	li	$3,1			# 0x1
206	sb	$3,%lo(completed.1269)($2)
207	b	$L3
208	nop
209
210$L8:
211	nop
212$L3:
213	lw	$31,28($sp)
214	addiu	$sp,$sp,32
215	j	$31
216	nop
217
218	.set	macro
219	.set	reorder
220	.end	__do_global_dtors_aux
221	.size	__do_global_dtors_aux, .-__do_global_dtors_aux
222	.local	completed.1269
223	.comm	completed.1269,1,1
224	.local	object.1265
225	.comm	object.1265,24,4
226	.weak	__deregister_frame_info
227	.weak	__cxa_finalize
228	.weak	__register_frame_info
229
230.include "__dso_handle.S"
231.include "atexit.S"
232