annotate libstdc++-v3/libsupc++/vtv_stubs.cc @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 // Copyright (C) 2012-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
2 //
kono
parents:
diff changeset
3 // This file is part of the GNU ISO C++ Library. This library is free
kono
parents:
diff changeset
4 // software; you can redistribute it and/or modify it under the
kono
parents:
diff changeset
5 // terms of the GNU General Public License as published by the
kono
parents:
diff changeset
6 // Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
7 // any later version.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 // This library is distributed in the hope that it will be useful,
kono
parents:
diff changeset
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
12 // GNU General Public License for more details.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 // Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
15 // permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
16 // 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 // You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
19 // a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
20 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
21 // <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 /* This is part of the vtable verification runtime library. For more
kono
parents:
diff changeset
24 information about this feature, see the comments in libvtv/vtv_rts.cc. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 /* The functions in this file are used to create the libvtv_stubs
kono
parents:
diff changeset
27 library, as part of the vtable verification feature. When building
kono
parents:
diff changeset
28 a binary without vtable verification, and linking it with a
kono
parents:
diff changeset
29 (possibly pre-built third-party) library that was built with
kono
parents:
diff changeset
30 verification, it is possible that vtable verification will fail due
kono
parents:
diff changeset
31 to incomplete data (rather than due to corrupt vtable pointers). In
kono
parents:
diff changeset
32 this case we need to give programmers a way of turning off the
kono
parents:
diff changeset
33 vtable verification in their libraries. They can do so by linking
kono
parents:
diff changeset
34 with the libvtv_stubs library, which (as you can see) will replace
kono
parents:
diff changeset
35 the real verification functions with a set of functions that do
kono
parents:
diff changeset
36 nothing (so no more verification failures/aborts). */
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 #include <cstddef>
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* weak symbols on Windows work differently than on Linux. To be able
kono
parents:
diff changeset
41 to switch vtv on and off on Windows two dlls are built. One with
kono
parents:
diff changeset
42 the sources from libvtv, the other from these stubs. Depending on
kono
parents:
diff changeset
43 which dll is placed in the folder of the executable the functions
kono
parents:
diff changeset
44 from libvtv or the stubs functions are used. */
kono
parents:
diff changeset
45 #if defined (__CYGWIN__) || defined (__MINGW32__)
kono
parents:
diff changeset
46 extern "C"
kono
parents:
diff changeset
47 void
kono
parents:
diff changeset
48 __VLTChangePermission(int);
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 void
kono
parents:
diff changeset
51 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
kono
parents:
diff changeset
52 void**);
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 void
kono
parents:
diff changeset
55 __VLTRegisterPair(void**, const void*, std::size_t,
kono
parents:
diff changeset
56 const void*);
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 const void*
kono
parents:
diff changeset
59 __VLTVerifyVtablePointer(void**, const void*);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 void
kono
parents:
diff changeset
62 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
kono
parents:
diff changeset
63 void**);
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 void
kono
parents:
diff changeset
66 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
kono
parents:
diff changeset
67 const char*, const char*);
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 const void*
kono
parents:
diff changeset
70 __VLTVerifyVtablePointerDebug(void**, const void*, const char*,
kono
parents:
diff changeset
71 const char*);
kono
parents:
diff changeset
72 #else
kono
parents:
diff changeset
73 // Declare as weak for libsupc++, strong definitions are in libvtv.
kono
parents:
diff changeset
74 #if __GXX_WEAK__
kono
parents:
diff changeset
75 extern "C"
kono
parents:
diff changeset
76 void
kono
parents:
diff changeset
77 __VLTChangePermission(int) __attribute__((weak));
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 void
kono
parents:
diff changeset
80 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
kono
parents:
diff changeset
81 void**) __attribute__((weak));
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 void
kono
parents:
diff changeset
84 __VLTRegisterPair(void**, const void*, std::size_t,
kono
parents:
diff changeset
85 const void*) __attribute__((weak));
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 const void*
kono
parents:
diff changeset
88 __VLTVerifyVtablePointer(void**, const void*) __attribute__((weak));
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 void
kono
parents:
diff changeset
91 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
kono
parents:
diff changeset
92 void**) __attribute__((weak));
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 void
kono
parents:
diff changeset
95 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
kono
parents:
diff changeset
96 const char*, const char*) __attribute__((weak));
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 const void*
kono
parents:
diff changeset
99 __VLTVerifyVtablePointerDebug(void**, const void*, const char*,
kono
parents:
diff changeset
100 const char*) __attribute__((weak));
kono
parents:
diff changeset
101 #endif
kono
parents:
diff changeset
102 #endif
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 // Stub definitions.
kono
parents:
diff changeset
105 extern "C"
kono
parents:
diff changeset
106 void
kono
parents:
diff changeset
107 __VLTChangePermission(int)
kono
parents:
diff changeset
108 { }
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 void
kono
parents:
diff changeset
111 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t, void**)
kono
parents:
diff changeset
112 { }
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 void
kono
parents:
diff changeset
115 __VLTRegisterPair(void**, const void*, std::size_t, const void*)
kono
parents:
diff changeset
116 { }
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 const void*
kono
parents:
diff changeset
119 __VLTVerifyVtablePointer(void**, const void* vtable_ptr)
kono
parents:
diff changeset
120 { return vtable_ptr; }
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 void
kono
parents:
diff changeset
123 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t, void**)
kono
parents:
diff changeset
124 { }
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 void
kono
parents:
diff changeset
127 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
kono
parents:
diff changeset
128 const char*, const char*)
kono
parents:
diff changeset
129 { }
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 const void*
kono
parents:
diff changeset
132 __VLTVerifyVtablePointerDebug(void**, const void* vtable_ptr, const char*,
kono
parents:
diff changeset
133 const char*)
kono
parents:
diff changeset
134 { return vtable_ptr; }