| @@ -17,38 +17,43 @@ | | | @@ -17,38 +17,43 @@ |
17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 17 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 19 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | * POSSIBILITY OF SUCH DAMAGE. | | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __RCSID("$NetBSD: crtbegin.c,v 1.9 2014/05/06 16:02:10 joerg Exp $"); | | 30 | __RCSID("$NetBSD: crtbegin.c,v 1.10 2016/06/01 21:21:55 joerg Exp $"); |
31 | | | 31 | |
32 | #include "crtbegin.h" | | 32 | #include "crtbegin.h" |
33 | | | 33 | |
34 | typedef void (*fptr_t)(void); | | 34 | typedef void (*fptr_t)(void); |
35 | | | 35 | |
36 | __dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr"); | | 36 | __dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr"); |
37 | | | 37 | |
38 | __weakref_visible void Jv_RegisterClasses(const fptr_t *) | | 38 | __weakref_visible void Jv_RegisterClasses(const fptr_t *) |
39 | __weak_reference(_Jv_RegisterClasses); | | 39 | __weak_reference(_Jv_RegisterClasses); |
40 | | | 40 | |
41 | #if !defined(HAVE_INITFINI_ARRAY) | | 41 | #if !defined(HAVE_INITFINI_ARRAY) |
| | | 42 | __weakref_visible const fptr_t __CTOR_LIST__start[] |
| | | 43 | __weak_reference(__CTOR_LIST__); |
| | | 44 | __weakref_visible const fptr_t __CTOR_LIST__end[] |
| | | 45 | __weak_reference(__CTOR_LIST_END__); |
| | | 46 | |
42 | __dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = { | | 47 | __dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = { |
43 | (fptr_t) -1, | | 48 | (fptr_t) -1, |
44 | }; | | 49 | }; |
45 | __dso_hidden extern const fptr_t __CTOR_LIST_END__[]; | | 50 | __dso_hidden extern const fptr_t __CTOR_LIST_END__[]; |
46 | #endif | | 51 | #endif |
47 | | | 52 | |
48 | #ifdef SHARED | | 53 | #ifdef SHARED |
49 | __dso_hidden void *__dso_handle = &__dso_handle; | | 54 | __dso_hidden void *__dso_handle = &__dso_handle; |
50 | | | 55 | |
51 | __weakref_visible void cxa_finalize(void *) | | 56 | __weakref_visible void cxa_finalize(void *) |
52 | __weak_reference(__cxa_finalize); | | 57 | __weak_reference(__cxa_finalize); |
53 | #else | | 58 | #else |
54 | __dso_hidden void *__dso_handle; | | 59 | __dso_hidden void *__dso_handle; |
| @@ -80,56 +85,61 @@ __do_global_ctors_aux(void) | | | @@ -80,56 +85,61 @@ __do_global_ctors_aux(void) |
80 | return; | | 85 | return; |
81 | | | 86 | |
82 | __initialized = 1; | | 87 | __initialized = 1; |
83 | | | 88 | |
84 | #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) | | 89 | #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) |
85 | if (register_frame_info) | | 90 | if (register_frame_info) |
86 | register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object); | | 91 | register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object); |
87 | #endif | | 92 | #endif |
88 | | | 93 | |
89 | if (Jv_RegisterClasses && __JCR_LIST__[0] != 0) | | 94 | if (Jv_RegisterClasses && __JCR_LIST__[0] != 0) |
90 | Jv_RegisterClasses(__JCR_LIST__); | | 95 | Jv_RegisterClasses(__JCR_LIST__); |
91 | | | 96 | |
92 | #if !defined(HAVE_INITFINI_ARRAY) | | 97 | #if !defined(HAVE_INITFINI_ARRAY) |
93 | for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) { | | 98 | for (const fptr_t *p = __CTOR_LIST__end; p > __CTOR_LIST__start + 1; ) { |
94 | (*(*--p))(); | | 99 | (*(*--p))(); |
95 | } | | 100 | } |
96 | #endif | | 101 | #endif |
97 | } | | 102 | } |
98 | | | 103 | |
99 | #if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__) | | 104 | #if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__) |
100 | #if !defined(HAVE_INITFINI_ARRAY) | | 105 | #if !defined(HAVE_INITFINI_ARRAY) |
| | | 106 | __weakref_visible const fptr_t __DTOR_LIST__start[] |
| | | 107 | __weak_reference(__DTOR_LIST__); |
| | | 108 | __weakref_visible const fptr_t __DTOR_LIST__end[] |
| | | 109 | __weak_reference(__DTOR_LIST_END__); |
| | | 110 | |
101 | __dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = { | | 111 | __dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = { |
102 | (fptr_t) -1, | | 112 | (fptr_t) -1, |
103 | }; | | 113 | }; |
104 | __dso_hidden extern const fptr_t __DTOR_LIST_END__[]; | | 114 | __dso_hidden extern const fptr_t __DTOR_LIST_END__[]; |
105 | #endif | | 115 | #endif |
106 | | | 116 | |
107 | static void __do_global_dtors_aux(void) __used; | | 117 | static void __do_global_dtors_aux(void) __used; |
108 | | | 118 | |
109 | static void __section(".text.exit") | | 119 | static void __section(".text.exit") |
110 | __do_global_dtors_aux(void) | | 120 | __do_global_dtors_aux(void) |
111 | { | | 121 | { |
112 | static unsigned char __finished; | | 122 | static unsigned char __finished; |
113 | | | 123 | |
114 | if (__finished) | | 124 | if (__finished) |
115 | return; | | 125 | return; |
116 | | | 126 | |
117 | __finished = 1; | | 127 | __finished = 1; |
118 | | | 128 | |
119 | #ifdef SHARED | | 129 | #ifdef SHARED |
120 | if (cxa_finalize) | | 130 | if (cxa_finalize) |
121 | (*cxa_finalize)(__dso_handle); | | 131 | (*cxa_finalize)(__dso_handle); |
122 | #endif | | 132 | #endif |
123 | | | 133 | |
124 | #if !defined(HAVE_INITFINI_ARRAY) | | 134 | #if !defined(HAVE_INITFINI_ARRAY) |
125 | for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) { | | 135 | for (const fptr_t *p = __DTOR_LIST__start + 1; p < __DTOR_LIST__end; ) { |
126 | (*(*p++))(); | | 136 | (*(*p++))(); |
127 | } | | 137 | } |
128 | #endif | | 138 | #endif |
129 | | | 139 | |
130 | #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) | | 140 | #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) |
131 | if (deregister_frame_info) | | 141 | if (deregister_frame_info) |
132 | deregister_frame_info(__EH_FRAME_LIST__); | | 142 | deregister_frame_info(__EH_FRAME_LIST__); |
133 | #endif | | 143 | #endif |
134 | } | | 144 | } |
135 | #endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */ | | 145 | #endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */ |