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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [frv/] [frvbegin.c] - Blame information for rev 777

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

Line No. Rev Author Line
1 734 jeremybenn
/* Frv initialization file linked before all user modules
2
   Copyright (C) 1999, 2000, 2003, 2004, 2009 Free Software Foundation, Inc.
3
    Contributed by Red Hat, Inc.
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software ; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
 
12
   GCC is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY ; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   Under Section 7 of GPL version 3, you are granted additional
18
   permissions described in the GCC Runtime Library Exception, version
19
   3.1, as published by the Free Software Foundation.
20
 
21
   You should have received a copy of the GNU General Public License and
22
   a copy of the GCC Runtime Library Exception along with this program;
23
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
   <http://www.gnu.org/licenses/>.
25
 
26
   This file was originally taken from the file crtstuff.c in the
27
   main compiler directory, and simplified.  */
28
 
29
#include "defaults.h"
30
#include <stddef.h>
31
#include "../libgcc/unwind-dw2-fde.h"
32
#include "gbl-ctors.h"
33
 
34
/*  Declare a pointer to void function type.  */
35
#define STATIC static
36
 
37
#ifdef __FRV_UNDERSCORE__
38
#define UNDERSCORE "_"
39
#else
40
#define UNDERSCORE ""
41
#endif
42
 
43
#define INIT_SECTION_NEG_ONE(SECTION, FLAGS, NAME)                      \
44
__asm__ (".section " SECTION "," FLAGS "\n\t"                           \
45
         ".globl   " UNDERSCORE NAME "\n\t"                             \
46
         ".type    " UNDERSCORE NAME ",@object\n\t"                     \
47
         ".p2align  2\n"                                                \
48
         UNDERSCORE NAME ":\n\t"                                        \
49
         ".word     -1\n\t"                                             \
50
         ".previous")
51
 
52
#define INIT_SECTION(SECTION, FLAGS, NAME)                              \
53
__asm__ (".section " SECTION "," FLAGS "\n\t"                           \
54
         ".globl   " UNDERSCORE NAME "\n\t"                             \
55
         ".type    " UNDERSCORE NAME ",@object\n\t"                     \
56
         ".p2align  2\n"                                                \
57
         UNDERSCORE NAME ":\n\t"                                        \
58
         ".previous")
59
 
60
/* Beginning of .ctor/.dtor sections that provides a list of constructors and
61
   destructors to run.  */
62
 
63
INIT_SECTION_NEG_ONE (".ctors", "\"aw\"", "__CTOR_LIST__");
64
INIT_SECTION_NEG_ONE (".dtors", "\"aw\"", "__DTOR_LIST__");
65
 
66
/* Beginning of .eh_frame section that provides all of the exception handling
67
   tables.  */
68
 
69
INIT_SECTION (".eh_frame", "\"aw\"", "__EH_FRAME_BEGIN__");
70
 
71
#if ! __FRV_FDPIC__
72
/* In FDPIC, the linker itself generates this.  */
73
/* Beginning of .rofixup section that provides a list of pointers that we
74
   need to adjust.  */
75
 
76
INIT_SECTION (".rofixup", "\"a\"", "__ROFIXUP_LIST__");
77
#endif /* __FRV_FDPIC__ */
78
 
79
extern void __frv_register_eh(void) __attribute__((__constructor__));
80
extern void __frv_deregister_eh(void) __attribute__((__destructor__));
81
 
82
extern func_ptr __EH_FRAME_BEGIN__[];
83
 
84
/* Register the exception handling table as the first constructor.  */
85
void
86
__frv_register_eh (void)
87
{
88
  static struct object object;
89
  if (__register_frame_info)
90
    __register_frame_info (__EH_FRAME_BEGIN__, &object);
91
}
92
 
93
/* Note, do not declare __{,de}register_frame_info weak as it seems
94
   to interfere with the pic support.  */
95
 
96
/* Unregister the exception handling table as a deconstructor.  */
97
void
98
__frv_deregister_eh (void)
99
{
100
  static int completed = 0;
101
 
102
  if (completed)
103
    return;
104
 
105
  if (__deregister_frame_info)
106
    __deregister_frame_info (__EH_FRAME_BEGIN__);
107
 
108
  completed = 1;
109
}
110
 
111
/* Run the global destructors.  */
112
void
113
__do_global_dtors (void)
114
{
115
  static func_ptr *p = __DTOR_LIST__ + 1;
116
  while (*p)
117
    {
118
      p++;
119
      (*(p-1)) ();
120
    }
121
}
122
 
123
/* Run the global constructors.  */
124
void
125
__do_global_ctors (void)
126
{
127
  unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];
128
  unsigned i;
129
 
130
  if (nptrs == (unsigned long)-1)
131
    for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);
132
 
133
  for (i = nptrs; i >= 1; i--)
134
    __CTOR_LIST__[i] ();
135
 
136
  atexit (__do_global_dtors);
137
}
138
 
139
/* Subroutine called automatically by `main'.
140
   Compiling a global function named `main'
141
   produces an automatic call to this function at the beginning.
142
 
143
   For many systems, this routine calls __do_global_ctors.
144
   For systems which support a .init section we use the .init section
145
   to run __do_global_ctors, so we need not do anything here.  */
146
 
147
void
148
__main (void)
149
{
150
  /* Support recursive calls to `main': run initializers just once.  */
151
  static int initialized;
152
  if (! initialized)
153
    {
154
      initialized = 1;
155
      __do_global_ctors ();
156
    }
157
}

powered by: WebSVN 2.1.0

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