crtbegin.c revision 1.9.6.2 1 1.9.6.2 tls /*-
2 1.9.6.2 tls * Copyright (c) 2013 The NetBSD Foundation, Inc.
3 1.9.6.2 tls * All rights reserved.
4 1.9.6.2 tls *
5 1.9.6.2 tls * This code is derived from software contributed to The NetBSD Foundation
6 1.9.6.2 tls * by Matt Thomas of 3am Software Foundry.
7 1.9.6.2 tls *
8 1.9.6.2 tls * Redistribution and use in source and binary forms, with or without
9 1.9.6.2 tls * modification, are permitted provided that the following conditions
10 1.9.6.2 tls * are met:
11 1.9.6.2 tls * 1. Redistributions of source code must retain the above copyright
12 1.9.6.2 tls * notice, this list of conditions and the following disclaimer.
13 1.9.6.2 tls * 2. Redistributions in binary form must reproduce the above copyright
14 1.9.6.2 tls * notice, this list of conditions and the following disclaimer in the
15 1.9.6.2 tls * documentation and/or other materials provided with the distribution.
16 1.9.6.2 tls *
17 1.9.6.2 tls * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.9.6.2 tls * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.9.6.2 tls * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.9.6.2 tls * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.9.6.2 tls * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.9.6.2 tls * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.9.6.2 tls * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.9.6.2 tls * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.9.6.2 tls * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.9.6.2 tls * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.9.6.2 tls * POSSIBILITY OF SUCH DAMAGE.
28 1.9.6.2 tls */
29 1.9.6.2 tls #include <sys/cdefs.h>
30 1.9.6.2 tls __RCSID("$NetBSD: crtbegin.c,v 1.9.6.2 2014/08/20 00:02:07 tls Exp $");
31 1.9.6.2 tls
32 1.9.6.2 tls #include "crtbegin.h"
33 1.9.6.2 tls
34 1.9.6.2 tls typedef void (*fptr_t)(void);
35 1.9.6.2 tls
36 1.9.6.2 tls __dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr");
37 1.9.6.2 tls
38 1.9.6.2 tls __weakref_visible void Jv_RegisterClasses(const fptr_t *)
39 1.9.6.2 tls __weak_reference(_Jv_RegisterClasses);
40 1.9.6.2 tls
41 1.9.6.2 tls #if !defined(HAVE_INITFINI_ARRAY)
42 1.9.6.2 tls __dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = {
43 1.9.6.2 tls (fptr_t) -1,
44 1.9.6.2 tls };
45 1.9.6.2 tls __dso_hidden extern const fptr_t __CTOR_LIST_END__[];
46 1.9.6.2 tls #endif
47 1.9.6.2 tls
48 1.9.6.2 tls #ifdef SHARED
49 1.9.6.2 tls __dso_hidden void *__dso_handle = &__dso_handle;
50 1.9.6.2 tls
51 1.9.6.2 tls __weakref_visible void cxa_finalize(void *)
52 1.9.6.2 tls __weak_reference(__cxa_finalize);
53 1.9.6.2 tls #else
54 1.9.6.2 tls __dso_hidden void *__dso_handle;
55 1.9.6.2 tls #endif
56 1.9.6.2 tls
57 1.9.6.2 tls #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
58 1.9.6.2 tls __dso_hidden
59 1.9.6.2 tls #if !defined(__mips__)
60 1.9.6.2 tls const
61 1.9.6.2 tls #endif
62 1.9.6.2 tls long __EH_FRAME_LIST__[0] __section(".eh_frame");
63 1.9.6.2 tls
64 1.9.6.2 tls __weakref_visible void register_frame_info(const void *, const void *)
65 1.9.6.2 tls __weak_reference(__register_frame_info);
66 1.9.6.2 tls __weakref_visible void deregister_frame_info(const void *)
67 1.9.6.2 tls __weak_reference(__deregister_frame_info);
68 1.9.6.2 tls
69 1.9.6.2 tls static long dwarf_eh_object[8];
70 1.9.6.2 tls #endif
71 1.9.6.2 tls
72 1.9.6.2 tls static void __do_global_ctors_aux(void) __used;
73 1.9.6.2 tls
74 1.9.6.2 tls static void __section(".text.startup")
75 1.9.6.2 tls __do_global_ctors_aux(void)
76 1.9.6.2 tls {
77 1.9.6.2 tls static unsigned char __initialized;
78 1.9.6.2 tls
79 1.9.6.2 tls if (__initialized)
80 1.9.6.2 tls return;
81 1.9.6.2 tls
82 1.9.6.2 tls __initialized = 1;
83 1.9.6.2 tls
84 1.9.6.2 tls #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
85 1.9.6.2 tls if (register_frame_info)
86 1.9.6.2 tls register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object);
87 1.9.6.2 tls #endif
88 1.9.6.2 tls
89 1.9.6.2 tls if (Jv_RegisterClasses && __JCR_LIST__[0] != 0)
90 1.9.6.2 tls Jv_RegisterClasses(__JCR_LIST__);
91 1.9.6.2 tls
92 1.9.6.2 tls #if !defined(HAVE_INITFINI_ARRAY)
93 1.9.6.2 tls for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) {
94 1.9.6.2 tls (*(*--p))();
95 1.9.6.2 tls }
96 1.9.6.2 tls #endif
97 1.9.6.2 tls }
98 1.9.6.2 tls
99 1.9.6.2 tls #if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__)
100 1.9.6.2 tls #if !defined(HAVE_INITFINI_ARRAY)
101 1.9.6.2 tls __dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = {
102 1.9.6.2 tls (fptr_t) -1,
103 1.9.6.2 tls };
104 1.9.6.2 tls __dso_hidden extern const fptr_t __DTOR_LIST_END__[];
105 1.9.6.2 tls #endif
106 1.9.6.2 tls
107 1.9.6.2 tls static void __do_global_dtors_aux(void) __used;
108 1.9.6.2 tls
109 1.9.6.2 tls static void __section(".text.exit")
110 1.9.6.2 tls __do_global_dtors_aux(void)
111 1.9.6.2 tls {
112 1.9.6.2 tls static unsigned char __finished;
113 1.9.6.2 tls
114 1.9.6.2 tls if (__finished)
115 1.9.6.2 tls return;
116 1.9.6.2 tls
117 1.9.6.2 tls __finished = 1;
118 1.9.6.2 tls
119 1.9.6.2 tls #ifdef SHARED
120 1.9.6.2 tls if (cxa_finalize)
121 1.9.6.2 tls (*cxa_finalize)(__dso_handle);
122 1.9.6.2 tls #endif
123 1.9.6.2 tls
124 1.9.6.2 tls #if !defined(HAVE_INITFINI_ARRAY)
125 1.9.6.2 tls for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) {
126 1.9.6.2 tls (*(*p++))();
127 1.9.6.2 tls }
128 1.9.6.2 tls #endif
129 1.9.6.2 tls
130 1.9.6.2 tls #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
131 1.9.6.2 tls if (deregister_frame_info)
132 1.9.6.2 tls deregister_frame_info(__EH_FRAME_LIST__);
133 1.9.6.2 tls #endif
134 1.9.6.2 tls }
135 1.9.6.2 tls #endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */
136