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