This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
0024-libitm-weak-symbols.patch
200 lines (179 loc) · 6.93 KB
/
0024-libitm-weak-symbols.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
diff --git a/libitm/Makefile.am b/libitm/Makefile.am
index 1dce82d..8b133b3 100644
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -53,7 +53,6 @@ libitm_version_info = -version-info $(libtool_VERSION)
# Force link with C, not C++. For now, while we're using C++ we don't
# want or need libstdc++.
libitm_la_DEPENDENCIES = $(libitm_version_dep)
-libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
libitm_la_SOURCES = \
diff --git a/libitm/Makefile.in b/libitm/Makefile.in
index 138eeb1..f688e84 100644
--- a/libitm/Makefile.in
+++ b/libitm/Makefile.in
@@ -356,7 +356,6 @@ libitm_version_info = -version-info $(libtool_VERSION)
# Force link with C, not C++. For now, while we're using C++ we don't
# want or need libstdc++.
libitm_la_DEPENDENCIES = $(libitm_version_dep)
-libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
libitm_la_SOURCES = aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc \
barrier.cc beginend.cc clone.cc eh_cpp.cc local.cc query.cc \
@@ -473,7 +472,7 @@ clean-toolexeclibLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libitm.la: $(libitm_la_OBJECTS) $(libitm_la_DEPENDENCIES) $(EXTRA_libitm_la_DEPENDENCIES)
- $(libitm_la_LINK) -rpath $(toolexeclibdir) $(libitm_la_OBJECTS) $(libitm_la_LIBADD) $(LIBS)
+ $(CXXLINK) $(libitm_la_LDFLAGS) -rpath $(toolexeclibdir) $(libitm_la_OBJECTS) $(libitm_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
diff --git a/libitm/alloc_cpp.cc b/libitm/alloc_cpp.cc
index 1d52e89..9722a0b 100644
--- a/libitm/alloc_cpp.cc
+++ b/libitm/alloc_cpp.cc
@@ -50,24 +50,30 @@ using namespace GTM;
/* Everything from libstdc++ is weak, to avoid requiring that library
to be linked into plain C applications using libitm.so. */
+#if defined(__CYGWIN__) && defined(PIC)
+#define WEAK
+#else
+#define WEAK __attribute__((weak))
+#endif
+
extern "C" {
-extern void *_ZnwX (size_t) __attribute__((weak));
-extern void _ZdlPv (void *) __attribute__((weak));
-extern void _ZdlPvX (void *, size_t) __attribute__((weak));
-extern void *_ZnaX (size_t) __attribute__((weak));
-extern void _ZdaPv (void *) __attribute__((weak));
+extern void *_ZnwX (size_t) WEAK;
+extern void _ZdlPv (void *) WEAK;
+extern void _ZdlPvX (void *, size_t) WEAK;
+extern void *_ZnaX (size_t) WEAK;
+extern void _ZdaPv (void *) WEAK;
typedef const struct nothrow_t { } *c_nothrow_p;
-extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
-extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
+extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
+extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
extern void _ZdlPvXRKSt9nothrow_t
-(void *, size_t, c_nothrow_p) __attribute__((weak));
-extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
-extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
+(void *, size_t, c_nothrow_p) WEAK;
+extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
+extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
-#if !defined (HAVE_ELF_STYLE_WEAKREF)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined(PIC)
void *_ZnwX (size_t) { return NULL; }
void _ZdlPv (void *) { return; }
void _ZdlPvX (void *, size_t) { return; }
diff --git a/libitm/beginend.cc b/libitm/beginend.cc
index 20b5547..3e19441 100644
--- a/libitm/beginend.cc
+++ b/libitm/beginend.cc
@@ -25,6 +25,24 @@
#include "libitm_i.h"
#include <pthread.h>
+#if defined(__CYGWIN__) && defined(PIC)
+#define WEAK
+#else
+#define WEAK __attribute__((weak))
+#endif
+
+/* Everything from libgcc_s is weak, to avoid requiring that library
+ to be linked into plain C applications using libitm.so. */
+
+extern "C" {
+
+extern void _Unwind_DeleteException (_Unwind_Exception*) WEAK;
+
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined(PIC)
+void _Unwind_DeleteException (_Unwind_Exception *) { return; }
+#endif /* HAVE_ELF_STYLE_WEAKREF */
+
+}
using namespace GTM;
diff --git a/libitm/configure.tgt b/libitm/configure.tgt
index e84382f..8dbe036 100644
--- a/libitm/configure.tgt
+++ b/libitm/configure.tgt
@@ -141,7 +141,7 @@ case "${target}" in
*-*-gnu* | *-*-k*bsd*-gnu \
| *-*-netbsd* | *-*-freebsd* | *-*-openbsd* \
| *-*-solaris2* | *-*-sysv4* | *-*-hpux11* \
- | *-*-darwin* | *-*-aix* | *-*-dragonfly*)
+ | *-*-darwin* | *-*-aix* | *-*-dragonfly* | *-*-cygwin*)
# POSIX system. The OS is supported.
;;
diff --git a/libitm/eh_cpp.cc b/libitm/eh_cpp.cc
index a6c06b5..a4ba223 100644
--- a/libitm/eh_cpp.cc
+++ b/libitm/eh_cpp.cc
@@ -77,7 +77,11 @@ using namespace GTM;
/* Everything from libstdc++ is weak, to avoid requiring that library
to be linked into plain C applications using libitm.so. */
+#if defined(__CYGWIN__) && defined(PIC)
+#define WEAK
+#else
#define WEAK __attribute__((weak))
+#endif
extern "C" {
@@ -95,14 +99,13 @@ extern void __cxa_end_catch (void) WEAK;
extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
extern __cxa_eh_globals *__cxa_get_globals (void) WEAK;
-#if !defined (HAVE_ELF_STYLE_WEAKREF)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined(PIC)
void *__cxa_allocate_exception (size_t) { return NULL; }
void __cxa_free_exception (void *) { return; }
void __cxa_throw (void *, void *, void *) { return; }
void *__cxa_begin_catch (void *) { return NULL; }
void __cxa_end_catch (void) { return; }
void __cxa_tm_cleanup (void *, void *, unsigned int) { return; }
-void _Unwind_DeleteException (_Unwind_Exception *) { return; }
__cxa_eh_globals *__cxa_get_globals (void) { return NULL; }
#endif /* HAVE_ELF_STYLE_WEAKREF */
@@ -176,9 +179,10 @@ _ITM_cxa_end_catch (void)
void
GTM::gtm_thread::init_cpp_exceptions ()
{
+ __cxa_eh_globals *(*__cxa_get_globals_ptr)() = &__cxa_get_globals;
// Only save and restore the number of uncaught exceptions if this is
// actually used in the program.
- if (__cxa_get_globals != NULL && __cxa_get_globals () != 0)
+ if (__cxa_get_globals_ptr != NULL && __cxa_get_globals () != 0)
cxa_uncaught_count_ptr = &__cxa_get_globals ()->uncaughtExceptions;
else
cxa_uncaught_count_ptr = 0;
diff --git a/libitm/libitm_i.h b/libitm/libitm_i.h
index a8cff57..52d2069 100644
--- a/libitm/libitm_i.h
+++ b/libitm/libitm_i.h
@@ -37,11 +37,6 @@
#include <string.h>
#include <unwind.h>
#include "local_atomic"
-
-/* Don't require libgcc_s.so for exceptions. */
-extern void _Unwind_DeleteException (_Unwind_Exception*) __attribute__((weak));
-
-
#include "common.h"
namespace GTM HIDDEN {
diff --git a/libitm/method-serial.cc b/libitm/method-serial.cc
index a151b66..3f47f58 100644
--- a/libitm/method-serial.cc
+++ b/libitm/method-serial.cc
@@ -24,12 +24,14 @@
#include "libitm_i.h"
+#if 0 // !defined(__CYGWIN__) || !defined(PIC)
// Avoid a dependency on libstdc++ for the pure virtuals in abi_dispatch.
extern "C" void HIDDEN
__cxa_pure_virtual ()
{
abort ();
}
+#endif
using namespace GTM;