1 /* Copyright (C) 1991, 1992, 2003, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 In addition to the permissions in the GNU Lesser General Public
15 License, the Free Software Foundation gives you unlimited
16 permission to link the compiled version of this file with other
17 programs, and to distribute those programs without any restriction
18 coming from the use of this file. (The GNU Lesser General Public
19 License restrictions do apply in other respects; for example, they
20 cover modification of the file, and distribution when not linked
21 into another program.)
23 You should have received a copy of the GNU Lesser General Public
24 License along with the GNU C Library; see the file COPYING.LIB. If
25 not, see <http://www.gnu.org/licenses/>. */
28 /* Based on ../i386/crt0.S and newlib's libgloss/frv/crt0.S */
31 When we enter this piece of code, the program stack looks like this:
32 argc argument counter (integer)
33 argv[0] program name (pointer)
34 argv[1...N] program args (pointers)
35 argv[argc-1] end of args (integer)
37 env[0...N] environment variables (pointers)
40 Also, GR16 holds a pointer to a memory map. */
46 .type _start,%function
47 #if defined L_crt0 || defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__
48 .type __uClibc_main,%function
52 .type __uClibc_start_main,%function
55 /* Make sure the stack pointer is properly aligned. Save the
56 original value in gr21 such that we can get to arguments and
60 /* At program start-up, gr16 contains a pointer to a memory
61 map, that we use to relocate addresses. */
65 sethi.p #gprelhi(.Lcall), gr5
66 setlo #gprello(.Lcall), gr5
68 /* gr4 now holds the _gp address. */
71 sethi.p #gprelhi(__ROFIXUP_LIST__), gr9
72 sethi #gprelhi(__ROFIXUP_END__), gr10
73 setlo.p #gprello(__ROFIXUP_LIST__), gr9
74 setlo #gprello(__ROFIXUP_END__), gr10
80 /* gr17 now holds the self-relocated _GLOBAL_OFFSET_TABLE_
81 address, because the linker added its unrelocated address as
82 the last entry in the ROFIXUP list, and __self_reloc returns
83 the last entry, relocated. */
85 /* Prepare arguments for uClibc main. */
92 /* Set up an invalid (NULL return address, NULL frame pointer)
93 callers stack frame so anybody unrolling the stack knows where
98 #if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__
99 /* Pass .init and .fini arguments to __uClibc_start_main(). */
100 sethi.p #gotfuncdeschi(_init), gr11
101 sethi #gotfuncdeschi(_fini), gr12
102 setlo.p #gotfuncdesclo(_init), gr11
103 setlo #gotfuncdesclo(_fini), gr12
104 ld.p @(gr11, gr17), gr11
106 ld.p @(gr12, gr17), gr12
107 call __uClibc_start_main
113 /* Crash if somehow `exit' returns anyways. */
115 .size _start,.-_start
117 /* Define a symbol for the first piece of initialized data. */
123 data_start = __data_start