blob: 40b689eeb4b3abe9de418a6fdce9edcfe2b74c04 [file] [log] [blame]
Raghu Gandham405b8022012-07-25 18:16:42 -07001/*
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__
Raghu Gandham405b8022012-07-25 18:16:42 -070073
74 .section .preinit_array, "aw"
75 .type __PREINIT_ARRAY__, @object
76 .globl __PREINIT_ARRAY__
77__PREINIT_ARRAY__:
78 .long -1
79
80 .section .init_array, "aw"
81 .type __INIT_ARRAY__, @object
82 .globl __INIT_ARRAY__
83__INIT_ARRAY__:
84 .long -1
85
86 .section .fini_array, "aw"
87 .type __FINI_ARRAY__, @object
88 .globl __FINI_ARRAY__
89__FINI_ARRAY__:
90 .long -1
91 .long __do_global_dtors_aux
92
Raghu Gandham405b8022012-07-25 18:16:42 -070093 .abicalls
94 .text
95 .align 2
96 .set nomips16
97 .ent __do_global_dtors_aux
98 .type __do_global_dtors_aux, @function
99__do_global_dtors_aux:
100 .frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
101 .mask 0x80000000,-4
102 .fmask 0x00000000,0
103 .set noreorder
104 .cpload $25
105 .set nomacro
106 addiu $sp,$sp,-32
107 sw $31,28($sp)
108 .cprestore 16
109 lw $2,%got(completed.1269)($28)
110 lbu $2,%lo(completed.1269)($2)
111 bne $2,$0,$L8
112 nop
113
114$L4:
115 lw $2,%got(__cxa_finalize)($28)
116 beq $2,$0,$L6
117 nop
118
119 lw $2,%got(__dso_handle)($28)
120 lw $4,0($2)
121 lw $25,%call16(__cxa_finalize)($28)
122 .reloc 1f,R_MIPS_JALR,__cxa_finalize
1231: jalr $25
124 nop
125
126 lw $28,16($sp)
127$L6:
128 lw $2,%got(completed.1269)($28)
129 li $3,1 # 0x1
130 sb $3,%lo(completed.1269)($2)
131$L8:
132 lw $31,28($sp)
133 addiu $sp,$sp,32
134 j $31
135 nop
136
137 .set macro
138 .set reorder
139 .end __do_global_dtors_aux
140 .size __do_global_dtors_aux, .-__do_global_dtors_aux
141 .local completed.1269
142 .comm completed.1269,1,1
143 .weak __cxa_finalize
144
145#include "__dso_handle.S"
146#include "atexit.S"