]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/libsupc++/vtv_stubs.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / vtv_stubs.cc
CommitLineData
7adcbafe 1// Copyright (C) 2012-2022 Free Software Foundation, Inc.
2077db1b
CT
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.
8
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.
13
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.
17
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/>.
22
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. */
25
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). */
37
38#include <cstddef>
39
f7f049fa
CT
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__)
46extern "C"
47void
48__VLTChangePermission(int);
49
50void
51__VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
52 void**);
53
54void
55__VLTRegisterPair(void**, const void*, std::size_t,
56 const void*);
57
58const void*
59__VLTVerifyVtablePointer(void**, const void*);
60
61void
62__VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
63 void**);
64
65void
66__VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
67 const char*, const char*);
68
69const void*
70__VLTVerifyVtablePointerDebug(void**, const void*, const char*,
71 const char*);
72#else
2077db1b
CT
73// Declare as weak for libsupc++, strong definitions are in libvtv.
74#if __GXX_WEAK__
75extern "C"
76void
77__VLTChangePermission(int) __attribute__((weak));
78
79void
80__VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
81 void**) __attribute__((weak));
82
83void
84__VLTRegisterPair(void**, const void*, std::size_t,
85 const void*) __attribute__((weak));
86
87const void*
88__VLTVerifyVtablePointer(void**, const void*) __attribute__((weak));
89
90void
91__VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
92 void**) __attribute__((weak));
93
94void
95__VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
96 const char*, const char*) __attribute__((weak));
97
98const void*
99__VLTVerifyVtablePointerDebug(void**, const void*, const char*,
100 const char*) __attribute__((weak));
101#endif
f7f049fa 102#endif
2077db1b
CT
103
104// Stub definitions.
105extern "C"
106void
107__VLTChangePermission(int)
108{ }
109
110void
111__VLTRegisterSet(void**, const void*, std::size_t, std::size_t, void**)
112{ }
113
114void
115__VLTRegisterPair(void**, const void*, std::size_t, const void*)
116{ }
117
118const void*
119__VLTVerifyVtablePointer(void**, const void* vtable_ptr)
120{ return vtable_ptr; }
121
122void
123__VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t, void**)
124{ }
125
126void
127__VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
128 const char*, const char*)
129{ }
130
131const void*
132__VLTVerifyVtablePointerDebug(void**, const void* vtable_ptr, const char*,
133 const char*)
134{ return vtable_ptr; }