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 56 1: 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 # Use jalr intead of jr so stack unwinding past __libc_init can terminate at _start 68 jalr $t9 69 move $t9, $0 70 j $t9 71 .end __start 72 73 1: .long __PREINIT_ARRAY__ 74 .long __INIT_ARRAY__ 75 .long __FINI_ARRAY__ 76 .long __CTOR_LIST__ 77 .long __DTOR_LIST__ 78 79 .section .preinit_array, "aw" 80 .type __PREINIT_ARRAY__, @object 81 .globl __PREINIT_ARRAY__ 82 __PREINIT_ARRAY__: 83 .long -1 84 85 .section .init_array, "aw" 86 .type __INIT_ARRAY__, @object 87 .globl __INIT_ARRAY__ 88 __INIT_ARRAY__: 89 .long -1 90 .long frame_dummy 91 92 .section .fini_array, "aw" 93 .type __FINI_ARRAY__, @object 94 .globl __FINI_ARRAY__ 95 __FINI_ARRAY__: 96 .long -1 97 .long __do_global_dtors_aux 98 99 .section .ctors, "aw" 100 .type __CTOR_LIST__, @object 101 .globl __CTOR_LIST__ 102 __CTOR_LIST__: 103 .long -1 104 105 .section .dtors, "aw" 106 .type __DTOR_LIST__, @object 107 .globl __DTOR_LIST__ 108 __DTOR_LIST__: 109 .long -1 110 111 .abicalls 112 .section .eh_frame,"a",@progbits 113 .align 2 114 .type __EH_FRAME_BEGIN__, @object 115 .size __EH_FRAME_BEGIN__, 0 116 __EH_FRAME_BEGIN__: 117 .text 118 .align 2 119 .set nomips16 120 .ent frame_dummy 121 .type frame_dummy, @function 122 frame_dummy: 123 .frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8 124 .mask 0x80000000,-4 125 .fmask 0x00000000,0 126 .set noreorder 127 .cpload $25 128 .set nomacro 129 addiu $sp,$sp,-32 130 sw $31,28($sp) 131 .cprestore 16 132 lw $2,%got(__register_frame_info)($28) 133 beq $2,$0,$L1 134 nop 135 136 lw $2,%got(__EH_FRAME_BEGIN__)($28) 137 addiu $4,$2,%lo(__EH_FRAME_BEGIN__) 138 lw $2,%got(object.1265)($28) 139 addiu $5,$2,%lo(object.1265) 140 lw $2,%call16(__register_frame_info)($28) 141 move $25,$2 142 .reloc 1f,R_MIPS_JALR,__register_frame_info 143 1: jalr $25 144 nop 145 146 lw $28,16($sp) 147 $L1: 148 lw $31,28($sp) 149 addiu $sp,$sp,32 150 j $31 151 nop 152 153 .text 154 .set macro 155 .set reorder 156 .end frame_dummy 157 .size frame_dummy, .-frame_dummy 158 .align 2 159 .set nomips16 160 .ent __do_global_dtors_aux 161 .type __do_global_dtors_aux, @function 162 __do_global_dtors_aux: 163 .frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8 164 .mask 0x80000000,-4 165 .fmask 0x00000000,0 166 .set noreorder 167 .cpload $25 168 .set nomacro 169 addiu $sp,$sp,-32 170 sw $31,28($sp) 171 .cprestore 16 172 lw $2,%got(completed.1269)($28) 173 lbu $2,%lo(completed.1269)($2) 174 bne $2,$0,$L8 175 nop 176 177 $L4: 178 lw $2,%got(__cxa_finalize)($28) 179 beq $2,$0,$L6 180 nop 181 182 lw $2,%got(__dso_handle)($28) 183 lw $2,0($2) 184 move $4,$2 185 lw $2,%call16(__cxa_finalize)($28) 186 move $25,$2 187 .reloc 1f,R_MIPS_JALR,__cxa_finalize 188 1: jalr $25 189 nop 190 191 lw $28,16($sp) 192 $L6: 193 lw $2,%got(__deregister_frame_info)($28) 194 beq $2,$0,$L7 195 nop 196 197 lw $2,%got(__EH_FRAME_BEGIN__)($28) 198 addiu $4,$2,%lo(__EH_FRAME_BEGIN__) 199 lw $2,%call16(__deregister_frame_info)($28) 200 move $25,$2 201 .reloc 1f,R_MIPS_JALR,__deregister_frame_info 202 1: jalr $25 203 nop 204 205 lw $28,16($sp) 206 $L7: 207 lw $2,%got(completed.1269)($28) 208 li $3,1 # 0x1 209 sb $3,%lo(completed.1269)($2) 210 b $L3 211 nop 212 213 $L8: 214 nop 215 $L3: 216 lw $31,28($sp) 217 addiu $sp,$sp,32 218 j $31 219 nop 220 221 .set macro 222 .set reorder 223 .end __do_global_dtors_aux 224 .size __do_global_dtors_aux, .-__do_global_dtors_aux 225 .local completed.1269 226 .comm completed.1269,1,1 227 .local object.1265 228 .comm object.1265,24,4 229 .weak __deregister_frame_info 230 .weak __cxa_finalize 231 .weak __register_frame_info 232 233 .include "__dso_handle.S" 234 .include "atexit.S" 235