Raghu Gandham | 405b802 | 2012-07-25 18:16:42 -0700 | [diff] [blame] | 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 | j $t9 |
| 68 | .end __start |
| 69 | |
| 70 | 1: .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 | |
| 88 | .section .fini_array, "aw" |
| 89 | .type __FINI_ARRAY__, @object |
| 90 | .globl __FINI_ARRAY__ |
| 91 | __FINI_ARRAY__: |
| 92 | .long -1 |
| 93 | .long __do_global_dtors_aux |
| 94 | |
| 95 | .section .ctors, "aw" |
| 96 | .type __CTOR_LIST__, @object |
| 97 | .globl __CTOR_LIST__ |
| 98 | __CTOR_LIST__: |
| 99 | .long -1 |
| 100 | |
| 101 | .section .dtors, "aw" |
| 102 | .type __DTOR_LIST__, @object |
| 103 | .globl __DTOR_LIST__ |
| 104 | __DTOR_LIST__: |
| 105 | .long -1 |
| 106 | |
| 107 | .abicalls |
| 108 | .text |
| 109 | .align 2 |
| 110 | .set nomips16 |
| 111 | .ent __do_global_dtors_aux |
| 112 | .type __do_global_dtors_aux, @function |
| 113 | __do_global_dtors_aux: |
| 114 | .frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8 |
| 115 | .mask 0x80000000,-4 |
| 116 | .fmask 0x00000000,0 |
| 117 | .set noreorder |
| 118 | .cpload $25 |
| 119 | .set nomacro |
| 120 | addiu $sp,$sp,-32 |
| 121 | sw $31,28($sp) |
| 122 | .cprestore 16 |
| 123 | lw $2,%got(completed.1269)($28) |
| 124 | lbu $2,%lo(completed.1269)($2) |
| 125 | bne $2,$0,$L8 |
| 126 | nop |
| 127 | |
| 128 | $L4: |
| 129 | lw $2,%got(__cxa_finalize)($28) |
| 130 | beq $2,$0,$L6 |
| 131 | nop |
| 132 | |
| 133 | lw $2,%got(__dso_handle)($28) |
| 134 | lw $4,0($2) |
| 135 | lw $25,%call16(__cxa_finalize)($28) |
| 136 | .reloc 1f,R_MIPS_JALR,__cxa_finalize |
| 137 | 1: jalr $25 |
| 138 | nop |
| 139 | |
| 140 | lw $28,16($sp) |
| 141 | $L6: |
| 142 | lw $2,%got(completed.1269)($28) |
| 143 | li $3,1 # 0x1 |
| 144 | sb $3,%lo(completed.1269)($2) |
| 145 | $L8: |
| 146 | lw $31,28($sp) |
| 147 | addiu $sp,$sp,32 |
| 148 | j $31 |
| 149 | nop |
| 150 | |
| 151 | .set macro |
| 152 | .set reorder |
| 153 | .end __do_global_dtors_aux |
| 154 | .size __do_global_dtors_aux, .-__do_global_dtors_aux |
| 155 | .local completed.1269 |
| 156 | .comm completed.1269,1,1 |
| 157 | .weak __cxa_finalize |
| 158 | |
| 159 | #include "__dso_handle.S" |
| 160 | #include "atexit.S" |