OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [libgloss/] [cris/] [lcrt0.c] - Blame information for rev 617

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Support for cris*-axis-linux-gnu and src/sim/cris simulator.
2
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Axis Communications.
3
   All rights reserved.
4
 
5
   Redistribution and use in source and binary forms, with or without
6
   modification, are permitted provided that the following conditions
7
   are met:
8
 
9
   1. Redistributions of source code must retain the above copyright
10
      notice, this list of conditions and the following disclaimer.
11
 
12
   2. Neither the name of Axis Communications nor the names of its
13
      contributors may be used to endorse or promote products derived
14
      from this software without specific prior written permission.
15
 
16
   THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
17
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
20
   COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21
   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25
   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26
   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
   POSSIBILITY OF SUCH DAMAGE.  */
28
 
29
#include "linunistd.h"
30
 
31
extern void exit (int) __attribute ((__noreturn__));
32
 
33
__asm__ (".syntax no_register_prefix");
34
 
35
#ifdef __ELF__
36
/* This simulator magic for an earlier simulator was supposed to be
37
   found two bytes before _start.  Let's keep it for sake of
38
   compatibility.  Trying to emit them with an ordinary const char[]
39
   and attribute section makes gcc barf; it doesn't like having the
40
   same section attribute for both code and data.
41
   The code is supposed to cause a crash if someone jumps to 0.  */
42
__asm__
43
 (
44
  " .section .startup,\"ax\",@progbits\n"
45
  " .byte 55,55\n"
46
  " move.d 0xbadacce5,r9\n"
47
  " clear.d [r9]\n"
48
  " setf\n"
49
  " setf\n"
50
  " .previous");
51
#endif
52
 
53
__asm__
54
 (
55
#ifdef __AOUT__
56
  " .text\n\t"
57
#elif defined (__ELF__)
58
  " .section .startup,\"ax\",@progbits\n"
59
#endif
60
  " .global __start\n"
61
  "__start:\n"
62
  /* SP must be set up by the simulator or the system.  */
63
 
64
  /* Find ARGC, ARGV and ENV.  */
65
  /* ARGC.  */
66
  " move.d [sp],r10\n"
67
 
68
  /* ARGV.  */
69
  " move.d sp,r11\n"
70
  " addq 4,r11\n"
71
 
72
  /* ENVP.  */
73
  " move.d sp,r12\n"
74
  " addi r10.d,r12\n"
75
  " addq 8,r12\n"
76
 
77
  /* Terminate R9 and R6; we don't have a "console_print_etrax" or system
78
     call function.  */
79
  " clear.d r9\n"
80
  " clear.d r6\n"
81
  " move.d __start1,r13\n"
82
  " jump r13\n"
83
  " setf\n"
84
#ifndef __AOUT__
85
  /* We rely on a.out not being in .data here.  Quite fragile, but
86
     covered by e.g. running the GCC test-suite for cris-unknown-aout. */
87
  " .previous"
88
#endif
89
  );
90
 
91
extern void _Libctors (void);
92
extern void _Libdtors (void);
93
 
94
extern void __init__start (void) __attribute ((weak));
95
extern void __aout__ctors (void) __attribute ((weak));
96
 
97
static void start1 () __asm__ ("__start1") __attribute ((__used__));
98
static void
99
start1 (int argc, char **argv, char **env)
100
{
101
#ifdef __ELF__
102
  /* For ELF systems, we call _init and register _fini with atexit.  */
103
  {
104
    extern void _init (void);
105
    extern void _fini (void);
106
    _init ();
107
    if (atexit (_fini) != 0)
108
      exit (-1);
109
  }
110
#else
111
  /* Constructors which may get here through the ELF .init section, when
112
     linking ELF and producing a.out.  */
113
  if (__init__start)
114
    __init__start ();
115
 
116
  if (__aout__ctors)
117
    __aout__ctors ();
118
 
119
  /* Call constructors in shared libraries. */
120
  _Libctors ();
121
 
122
  if (atexit (_Libdtors) != 0)
123
    exit (-1);
124
#endif
125
 
126
  /* Call the user program.  */
127
  exit (main (argc, argv, env));
128
}

powered by: WebSVN 2.1.0

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