kernel/eka/compsupp/rvct2_2/ucppinit_aeabi.cpp
changeset 266 0008ccd16016
parent 259 57b9594f5772
child 272 70a6efdb753f
child 281 13fbfa31d2ba
equal deleted inserted replaced
259:57b9594f5772 266:0008ccd16016
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "ARM EABI LICENCE.txt"
       
     5 // which accompanies this distribution, and is available
       
     6 // in kernel/eka/compsupp.
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // toplevel initialization/destruction routines for 'user side' code compiled 
       
    15 // with the ARMCC EABI compiler. intended for static linking
       
    16 // The code supports 2.2 both bpabi and non-bpabi. The values in .init_array are
       
    17 // pointers in both environments, so the library is common to both.
       
    18 // 
       
    19 //
       
    20 
       
    21 extern "C" {
       
    22 
       
    23 // This calls each of the compiler constructed functions referenced from pi_ctorvec.
       
    24 // These functions arrange to 'call' the appropriate constructor for the 'static' instance
       
    25 // (in fact the call may be inlined). If the class of the instance has a destructor then 
       
    26 // compiler records that this object needs 'destructing' at 'exit' time. It does this by 
       
    27 // calling the function __cxa_atexit. We provide our own definition of this.
       
    28 // 
       
    29 
       
    30 #ifdef __thumb
       
    31   __asm void __cpp_initialize__aeabi_(void)
       
    32     {
       
    33     CODE16
       
    34 #ifndef _NO_FP
       
    35     IMPORT    _fp_init [WEAK]
       
    36 #endif
       
    37     IMPORT    |SHT$$INIT_ARRAY$$Base| [WEAK]
       
    38     IMPORT    |SHT$$INIT_ARRAY$$Limit| [WEAK]
       
    39 
       
    40     // export std::nothrow from here
       
    41     EXPORT    _ZSt7nothrow
       
    42 
       
    43 #ifndef _NO_FP
       
    44     LDR      r0,fpinit
       
    45 #endif
       
    46     PUSH     {r4-r6,r14}
       
    47 #ifndef _NO_FP
       
    48     CMP      r0,#0
       
    49     BEQ      skip
       
    50     BL       _fp_init  ;
       
    51 skip
       
    52 #endif
       
    53     LDR      r4,base
       
    54     LDR      r5,limit
       
    55     B        check
       
    56 loop
       
    57     LDR      r0,[r4,#0]
       
    58 
       
    59     BLX      r0
       
    60     ADD      r4,#4
       
    61 check
       
    62     CMP      r4,r5
       
    63     BCC      loop
       
    64     POP      {r4-r6,pc}
       
    65 
       
    66 #ifndef _NO_FP
       
    67     ALIGN 4 
       
    68 fpinit
       
    69     DCD    _fp_init
       
    70 #endif
       
    71 
       
    72 // cheat - saved a whole 4 bytes!!! - value is never used
       
    73 _ZSt7nothrow
       
    74 base
       
    75     DCD    |SHT$$INIT_ARRAY$$Base|
       
    76 limit
       
    77     DCD    |SHT$$INIT_ARRAY$$Limit|
       
    78 
       
    79     }
       
    80 
       
    81 #else
       
    82   __asm void __cpp_initialize__aeabi_(void)
       
    83     {
       
    84     CODE32
       
    85 #ifndef _NO_FP
       
    86     IMPORT    _fp_init [WEAK]
       
    87 #endif
       
    88     IMPORT    |SHT$$INIT_ARRAY$$Base| [WEAK]
       
    89     IMPORT    |SHT$$INIT_ARRAY$$Limit| [WEAK]
       
    90 
       
    91     // export std::nothrow from here
       
    92     EXPORT    _ZSt7nothrow
       
    93 
       
    94 #ifndef _NO_FP
       
    95     LDR	     r0, fpinit
       
    96 #endif
       
    97     STMFD    r13!,{r3-r5,r14}
       
    98 #ifndef _NO_FP
       
    99     CMP      r0, #0
       
   100     BEQ	     skip
       
   101     BL	     _fp_init
       
   102 skip
       
   103 #endif
       
   104     LDR      r4,base
       
   105     LDR      r5,limit
       
   106     CMP      r4,r5
       
   107     LDMEQFD  r13!,{r3-r5,pc}
       
   108 loop
       
   109 	LDR      r0,[r4,#0]
       
   110 #ifdef __MARM_ARMV4__
       
   111     ADR      r14,ret
       
   112     MOV      pc,r0
       
   113 #else
       
   114     BLX      r0
       
   115 #endif
       
   116 ret
       
   117     ADD      r4,r4,#4
       
   118     CMP      r4,r5
       
   119     BNE      loop
       
   120     LDMFD    r13!,{r3-r5,pc}
       
   121 
       
   122 #ifndef _NO_FP
       
   123 fpinit
       
   124     DCD    _fp_init
       
   125 #endif
       
   126 
       
   127 base
       
   128     DCD    |SHT$$INIT_ARRAY$$Base|
       
   129 limit
       
   130     DCD    |SHT$$INIT_ARRAY$$Limit|
       
   131 
       
   132 // cheat - defining this here saves a whole 4 bytes!!! - value is never used
       
   133 _ZSt7nothrow
       
   134 
       
   135     }
       
   136 #endif
       
   137 
       
   138 }