OSDN Git Service

Initial sparc port, thanks to Mathew Bosworth <mbosworth@metaflow.com>,
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / sparc / crt0.S
1 /*
2  * xrt0.s for ERC32. 
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 675
16  * Mass Ave, Cambridge, MA 02139, USA.
17  *
18  */
19
20 /* code taken from leonccs 1.0 leon/src/libio/crt0.S 
21         I don't know if this is available anymore, now that LECCS
22         is out.  And I'm not sure if this source is in the LECCS distro  :(
23 */
24
25         .text
26 ! Original : 
27 !       .global __start, _main
28 ! uC-libc version : 
29         .global _start
30         .global __uClibc_main
31
32 ! Start the real-time clock with a tick of 14 clocks
33 !
34
35 _start:
36
37         save    %sp, -64, %sp
38
39         /* clear the bss */
40  
41         sethi %hi(edata),%g2
42         or    %g2,%lo(edata),%g2  ! g2 = start of bss
43         sethi %hi(_end),%g3
44         or    %g3,%lo(_end),%g3         ! g3 = end of bss
45         mov   %g0,%g1                   ! so std has two zeros
46 zerobss:
47         std    %g0,[%g2]
48         add    %g2,8,%g2
49         cmp    %g2,%g3
50         bleu,a zerobss
51         nop
52
53         /* move data segment to proper location */
54  
55 relocd:
56         set (_endtext),%g2              ! g2 = start of data in aout file
57         set (_environ),%g4              ! g4 = start of where data should go
58         set (_edata),%g3                ! g3 = end of where data should go
59         subcc   %g3, %g4, %g5           ! g5 = length of data
60
61         subcc   %g4, %g2, %g0           ! need to relocate data ?
62         ble     initok
63         ld      [%g4], %g6
64 !       subcc   %g6, 1, %g0
65 !       be      initok
66 mvdata:
67         subcc   %g5, 8, %g5
68         ldd     [%g2 + %g5], %g6
69         bg      mvdata
70         std     %g6, [%g4 + %g5]
71
72 initok:
73
74 !       call    _main
75         call    __uClibc_main
76         nop
77 ! Should not return from uClibc main()
78 !       ret
79 !       nop
80
81         .seg    "data"
82         .global .bdata
83 .bdata:
84         .align  8
85         .global _environ                ! first symbol in sdata
86 _environ:
87         .word   1
88
89
90