1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
20 /* When we enter this piece of code, the user stack looks like this:
21 * argc argument counter (integer)
22 * argv[0] program name (pointer)
23 * argv[1...N] program args (pointers)
25 * env[0...N] environment variables (pointers)
28 * When we are done here, we want
37 #if defined (__UCLIBC_FORMAT_SHARED_FLAT__) || defined (__UCLIBC_FORMAT_FLAT_SEP_DATA__)
41 #if !(defined L_Scrt1 && defined __UCLIBC_FORMAT_SHARED_FLAT__)
46 .type __start,STT_FUNC;
49 .global ___uClibc_main;
50 .type ___uClibc_main,STT_FUNC;
52 /* Stick in a dummy reference to main(), so that if an application
53 * is linking when the main() function is in a static library (.a)
54 * we can be sure that main() actually gets linked in */
60 #if defined(__BFIN_FDPIC__) && !defined(L_Scrt1)
61 /* P0 contains a pointer to the program's load map. */
68 R1.L = __ROFIXUP_LIST__;
69 R1.H = __ROFIXUP_LIST__;
70 R2.L = __ROFIXUP_END__;
71 R2.H = __ROFIXUP_END__;
82 /* clear the frame pointer and the L registers. */
89 #ifdef __ID_SHARED_LIB__
90 /* We know we have a local copy, so we can avoid the GOT. */
91 CALL ___shared_flat_add_library;
93 /* Load register R1 (argc) from the stack to its final resting place */
97 /* Copy argv pointer into R2 -- which its final resting place */
102 #ifndef __BFIN_FDPIC__
105 /* Pass highest stack pointer to the app. */
107 /* Store the pointer to ld.so's fini that we got in P1. */
110 /* Ok, now run uClibc's main() -- shouldn't return */
111 #if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__
113 #ifdef __BFIN_FDPIC__
114 R3 = [P3 + __init@FUNCDESC_GOT17M4];
115 #elif defined USE_GOT
116 R3 = [P5 + ___shared_flat_init@GOT];
124 #ifdef __BFIN_FDPIC__
125 R3 = [P3 + __fini@FUNCDESC_GOT17M4];
126 #elif defined USE_GOT
127 R3 = [P5 + ___shared_flat_fini@GOT];
133 #else /* no ctor/dtor handling */
139 #ifdef __BFIN_FDPIC__
140 R0 = [P3 + _main@FUNCDESC_GOT17M4];
141 #elif defined USE_GOT
142 R0 = [P5 + _main@GOT];
148 P0 = [P5 + ___uClibc_main@GOT];
151 jump.l ___uClibc_main;
158 .type lib_main,@function
161 /* We know we have a local copy, so we can avoid the GOT. */
162 JUMP.L ___shared_flat_add_library;
164 .hidden _current_shared_library_p5_offset_
167 .section .note.GNU-stack,"",%progbits