OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [cris/] [crt0.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Startup code compliant to the ELF CRIS ABI */
2
 
3
/* The first piece of initialized data.  */
4
int __data_start = 0;
5
 
6
static void start1 (int argc, char **argv) __attribute__ ((used, noreturn));
7
 
8
/*
9
 * It is important that this be the first function.
10
 * This file is the first thing in the text section.
11
 */
12
void
13
_start (void)
14
{
15
        /*
16
         * On the stack we have argc. We can calculate argv/envp
17
         * from that and the succeeding stack location, but fix so
18
         * we get the right calling convention (regs in r10/r11).
19
         *
20
         * Please view linux/fs/binfmt_elf.c for a complete
21
         * understanding of this.
22
         */
23
        __asm__ volatile("pop $r10");
24
        __asm__ volatile("move.d $sp, $r11");
25
        __asm__ volatile("jump start1");
26
}
27
 
28
#include <features.h>
29
 
30
extern void __uClibc_main(int argc, char **argv, char **envp)
31
         __attribute__ ((__noreturn__));
32
extern void __uClibc_start_main(int argc, char **argv, char **envp,
33
        void (*app_init)(void), void (*app_fini)(void))
34
         __attribute__ ((__noreturn__));
35
extern void weak_function _init(void);
36
extern void weak_function _fini(void);
37
 
38
/* Stick in a dummy reference to main(), so that if an application
39
 * is linking when the main() function is in a static library (.a)
40
 * we can be sure that main() actually gets linked in */
41
extern void main(int argc,void *argv,void *envp);
42
void (*__mainp)(int argc,void *argv,void *envp) = main;
43
 
44
static void
45
start1 (int argc, char **argv)
46
{
47
        char** environ;
48
 
49
        /* The environment starts just after ARGV.  */
50
        environ = &argv[argc + 1];
51
 
52
        /*
53
         * If the first thing after ARGV is the arguments
54
         * themselves, there is no environment.
55
         */
56
        if ((char *) environ == *argv)
57
                /*
58
                 * The environment is empty.  Make environ
59
                 * point at ARGV[ARGC], which is NULL.
60
                 */
61
                --environ;
62
 
63
#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
64
        /* Leave control to the libc */
65
        __uClibc_main(argc, argv, environ);
66
#else
67
        __uClibc_start_main(argc, argv, environ, _init, _fini);
68
#endif
69
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.