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/] [gcc-4.5.1/] [gcc/] [config/] [i386/] [cygming-crtbegin.c] - Blame information for rev 300

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

Line No. Rev Author Line
1 282 jeremybenn
/* crtbegin object for windows32 targets.
2
   Copyright (C) 2007, 2009  Free Software Foundation, Inc.
3
 
4
   Contributed by Danny Smith <dannysmith@users.sourceforge.net>
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify it under
9
the terms of the GNU General Public License as published by the Free
10
Software Foundation; either version 3, or (at your option) any later
11
version.
12
 
13
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16
for more details.
17
 
18
Under Section 7 of GPL version 3, you are granted additional
19
permissions described in the GCC Runtime Library Exception, version
20
3.1, as published by the Free Software Foundation.
21
 
22
You should have received a copy of the GNU General Public License and
23
a copy of the GCC Runtime Library Exception along with this program;
24
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25
<http://www.gnu.org/licenses/>.  */
26
 
27
/* Target machine header files require this define. */
28
#define IN_LIBGCC2
29
 
30
#include "auto-host.h"
31
#include "tconfig.h"
32
#include "tsystem.h"
33
#include "coretypes.h"
34
#include "tm.h"
35
#include "unwind-dw2-fde.h"
36
 
37
#define WIN32_LEAN_AND_MEAN
38
#include <windows.h>
39
 
40
#ifndef LIBGCC_SONAME
41
#define LIBGCC_SONAME "libgcc_s.dll"
42
#endif
43
 
44
#ifndef LIBGCJ_SONAME
45
#define LIBGCJ_SONAME "libgcj_s.dll"
46
#endif
47
 
48
 
49
/* Make the declarations weak.  This is critical for
50
   _Jv_RegisterClasses because it lives in libgcj.a  */
51
extern void __register_frame_info (const void *, struct object *)
52
                                   TARGET_ATTRIBUTE_WEAK;
53
extern void *__deregister_frame_info (const void *)
54
                                      TARGET_ATTRIBUTE_WEAK;
55
extern void _Jv_RegisterClasses (const void *) TARGET_ATTRIBUTE_WEAK;
56
 
57
#if defined(HAVE_LD_RO_RW_SECTION_MIXING)
58
# define EH_FRAME_SECTION_CONST const
59
#else
60
# define EH_FRAME_SECTION_CONST
61
#endif
62
 
63
/* Stick a label at the beginning of the frame unwind info so we can
64
   register/deregister it with the exception handling library code.  */
65
#if DWARF2_UNWIND_INFO
66
static EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
67
  __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
68
  = { };
69
 
70
static struct object obj;
71
#endif
72
 
73
#if TARGET_USE_JCR_SECTION
74
static void *__JCR_LIST__[]
75
  __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(4)))
76
  = { };
77
#endif
78
 
79
/* Pull in references from libgcc.a(unwind-dw2-fde.o) in the
80
   startfile. These are referenced by a ctor and dtor in crtend.o.  */
81
extern void __gcc_register_frame (void);
82
extern void __gcc_deregister_frame (void);
83
 
84
void
85
__gcc_register_frame (void)
86
{
87
#if DWARF2_UNWIND_INFO
88
/* Weak undefined symbols won't be pulled in from dlls; hence
89
   we first test if the dll is already loaded and, if so,
90
   get the symbol's address at run-time.  If the dll is not loaded,
91
   fallback to weak linkage to static archive.  */
92
 
93
  void (*register_frame_fn) (const void *, struct object *);
94
  HANDLE h = GetModuleHandle (LIBGCC_SONAME);
95
  if (h)
96
    register_frame_fn = (void (*) (const void *, struct object *))
97
                        GetProcAddress (h, "__register_frame_info");
98
  else
99
    register_frame_fn = __register_frame_info;
100
  if (register_frame_fn)
101
     register_frame_fn (__EH_FRAME_BEGIN__, &obj);
102
#endif
103
 
104
#if TARGET_USE_JCR_SECTION 
105
  if (__JCR_LIST__[0])
106
    {
107
      void (*register_class_fn) (const void *);
108
      HANDLE h = GetModuleHandle (LIBGCJ_SONAME);
109
      if (h)
110
        register_class_fn = (void (*) (const void *))
111
                             GetProcAddress (h, "_Jv_RegisterClasses");
112
      else
113
        register_class_fn = _Jv_RegisterClasses;
114
 
115
      if (register_class_fn)
116
        register_class_fn (__JCR_LIST__);
117
    }
118
#endif
119
}
120
 
121
void
122
__gcc_deregister_frame (void)
123
{
124
#if DWARF2_UNWIND_INFO
125
  void *  (*deregister_frame_fn) (const void *);
126
  HANDLE h = GetModuleHandle (LIBGCC_SONAME);
127
  if (h)
128
    deregister_frame_fn = (void* (*) (const void *))
129
                          GetProcAddress (h, "__deregister_frame_info");
130
  else
131
    deregister_frame_fn = __deregister_frame_info;
132
  if (deregister_frame_fn)
133
     deregister_frame_fn (__EH_FRAME_BEGIN__);
134
#endif
135
}

powered by: WebSVN 2.1.0

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