source: trunk/libs/newlib/src/libgloss/rx/crt0.S @ 621

Last change on this file since 621 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 5.0 KB
RevLine 
[444]1/* Copyright (c) 2008, 2009, 2011 Red Hat Incorporated.
2   All rights reserved.
3
4   Redistribution and use in source and binary forms, with or without
5   modification, are permitted provided that the following conditions
6   are met:
7
8     Redistributions of source code must retain the above copyright
9     notice, this list of conditions and the following disclaimer.
10
11     Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in the
13     documentation and/or other materials provided with the distribution.
14
15     The name of Red Hat Incorporated may not be used to endorse
16     or promote products derived from this software without specific
17     prior written permission.
18
19   This software is provided by the copyright holders and contributors
20   "AS IS" and any express or implied warranties, including, but not
21   limited to, the implied warranties of merchantability and fitness for
22   a particular purpose are disclaimed.  In no event shall Red Hat
23   incorporated be liable for any direct, indirect, incidental, special,
24   exemplary, or consequential damages (including, but not limited to,
25   procurement of substitute goods or services; loss of use, data, or
26   profits; or business interruption) however caused and on any theory of
27   liability, whether in contract, strict liability, or tort (including
28   negligence or otherwise) arising in any way out of the use of this
29   software, even if advised of the possibility of such damage.  */
30
31        .text
32
33        .global _start
34_start:
35.LFB2:
36        mvtc    #0, psw
37        /* Enable the DN bit - this should have been done for us by
38           the CPU reset, but it is best to make sure for ourselves.  */       
39        mvtc    #0x100, fpsw
40        mov     #__stack, r0
41        mvtc    #__vectors, intb
42
43        /* Copy the .data section from ROM into RAM.  */
44        mov     #__datastart, r1
45        mov     #__romdatastart, r2
46        mov     #__romdatacopysize, r3
47#ifdef __RX_DISALLOW_STRING_INSNS__
48        cmp     #0, r3
49        beq     2f
50
511:      mov.b   [r2+], r5
52        mov.b   r5, [r1+]
53        sub     #1, r3
54        bne     1b
552:     
56#else
57        smovf
58#endif
59
60        /* Initialise the contents of the .bss section.  */
61        mov     #__bssstart, r1
62        mov     #0, r2
63        mov     #__bsssize, r3
64        sstr.l
65
66        /* Initialize data pointer register(s).
67           Note: The registers used here should agree with the definition of
68           GP_BASE_REGNUM in gcc/config/rx/rx.h.
69           Note: We are assuming that -mint-register has not been used when
70           compiling the application.  */
71#ifdef _RX_PID
72        /* Initialise the constant data pointer and small data pointers.  */
73        mov     #__pid_base, r13
74        mov     #__gp, r12
75#else
76        /* Initialise the small data area pointer.  */
77        mov     #__gp, r13
78#endif
79       
80        bsr.a   __rx_init
81
82#ifdef PROFILE_SUPPORT  /* Defined in gcrt0.S.  */
83        mov     # _start, r1
84        mov     # _etext, r2
85        bsr.a   __monstartup
86#endif
87
88        mov     #0, r1 /* argc */
89        mov     #0, r2 /* argv */
90        mov     #0, r3 /* envv */
91        bsr.a   _main
92.LFE2:
93
94#ifdef PROFILE_SUPPORT
95        mov      r1, r13       ; Save return code.
96        bsr.a   __mcleanup
97        mov     r13, r1
98#endif
99
100        bsr.a   _exit
101
102        .global _rx_run_preinit_array
103        .type   _rx_run_preinit_array,@function
104_rx_run_preinit_array:
105        mov     #__preinit_array_start,r1
106        mov     #__preinit_array_end,r2
107        bra.a   _rx_run_inilist
108
109        .global _rx_run_init_array
110        .type   _rx_run_init_array,@function
111_rx_run_init_array:
112        mov     #__init_array_start,r1
113        mov     #__init_array_end,r2
114        mov     #4, r3
115        bra.a   _rx_run_inilist
116
117        .global _rx_run_fini_array
118        .type   _rx_run_fini_array,@function
119_rx_run_fini_array:
120        mov     #__fini_array_start,r2
121        mov     #__fini_array_end,r1
122        mov     #-4, r3
123        /* fall through */
124
125_rx_run_inilist:
126next_inilist:
127        cmp     r1,r2
128        beq.b   done_inilist
129        mov.l   [r1],r4
130        cmp     #-1, r4
131        beq.b   skip_inilist
132        cmp     #0, r4
133        beq.b   skip_inilist
134        pushm   r1-r3
135        jsr     r4
136        popm    r1-r3
137skip_inilist:
138        add     r3,r1
139        bra.b   next_inilist
140done_inilist:
141        rts
142
143        .section        .init,"ax"
144
145        .global __rx_init
146__rx_init:
147
148        .section        .fini,"ax"
149
150        .global __rx_fini
151__rx_fini:
152        bsr.a   _rx_run_fini_array
153
154        .section .rodata
155        .balign 4
156        .global __pid_base
157        .weak   __pid_base
158__pid_base:   
159
160        .section .sdata
161        .balign 4
162        .global __gp
163        .weak   __gp
164__gp:   
165
166        .section .data
167        .global ___dso_handle
168        .weak   ___dso_handle
169___dso_handle:
170        .long   0
171
172;;; Provide Dwarf unwinding information that will help GDB stop
173;;; backtraces at the right place.  This is stolen from assembly
174;;; code generated by GCC with -dA.
175        .section        .debug_frame,"",@progbits
176.Lframe0:
177        .4byte  .LECIE0-.LSCIE0 ; Length of Common Information Entry
178.LSCIE0:
179        .4byte  0xffffffff      ; CIE Identifier Tag
180        .byte   0x1     ; CIE Version
181        .ascii "\0"     ; CIE Augmentation
182        .uleb128 0x1    ; CIE Code Alignment Factor
183        .sleb128 -1     ; CIE Data Alignment Factor
184        .byte   0xd     ; CIE RA Column
185        .byte   0xc     ; DW_CFA_def_cfa
186        .uleb128 0xc
187        .uleb128 0x3
188        .byte   0x8d    ; DW_CFA_offset, column 0xd
189        .uleb128 0x3
190        .p2align 2
191.LECIE0:
192.LSFDE0:
193        .4byte  .LEFDE0-.LASFDE0        ; FDE Length
194.LASFDE0:
195        .4byte  .Lframe0        ; FDE CIE offset
196        .4byte  .LFB2           ; FDE initial location
197        .4byte  .LFE2-.LFB2     ; FDE address range
198        .byte   0xf             ; DW_CFA_def_cfa_expression
199        .uleb128 1              ; length of expression
200        .byte   0x30            ; DW_OP_lit0
201        .p2align 2
202.LEFDE0:
203
204        .text
Note: See TracBrowser for help on using the repository browser.