Home | History | Annotate | Download | only in arch-sh
      1 /*
      2  * Copyright (C) 2009 The Android Open 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  _init,#function
     31     .globl _init
     32 
     33 # The toolchain for SH-Linux does not produce INIT_ARRAY information which
     34 # bionic linker relies on.  Instead of it, The toolchain for SH-Linux produces
     35 # INIT information when it find the function whose name is '_init'.
     36 #
     37 _init:
     38     sts.l   pr, @-r15
     39     mov.l   r8, @-r15
     40     mov.l   0f, r8      /* first entry is invalid */
     41 .L_loop:
     42     add     #4, r8
     43     mov.l   @r8, r0
     44     cmp/eq  #0, r0      /* Zero terimnated. See 'soend.so'. */
     45     bt      .L_end
     46     jsr     @r0         /* invoke a constructor */
     47     nop
     48     bra     .L_loop
     49     nop
     50 .L_end:
     51     mov.l   @r15+, r8
     52     lds.l   @r15+, pr
     53 
     54     rts
     55     nop
     56 
     57     .balign 4
     58 0:  .long   __CTOR_LIST__
     59 
     60 # the .ctors section contains a list of pointers to "constructor"
     61 # functions that need to be called in order during C library initialization,
     62 # just before the program is being run. This is a C++ requirement
     63 #
     64 # the last entry shall be 0, and is defined in crtend.S
     65 #
     66     .section .ctors, "aw"
     67     .globl __CTOR_LIST__
     68 __CTOR_LIST__:
     69     .long   -1
     70 
     71