1 // Copyright (C) 2012-2024 Free Software Foundation, Inc.
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)
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). */
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__)
48 __VLTChangePermission(int);
51 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
55 __VLTRegisterPair(void**, const void*, std::size_t,
59 __VLTVerifyVtablePointer(void**, const void*);
62 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
66 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
67 const char*, const char*);
70 __VLTVerifyVtablePointerDebug(void**, const void*, const char*,
73 // Declare as weak for libsupc++, strong definitions are in libvtv.
77 __VLTChangePermission(int) __attribute__((weak
));
80 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
81 void**) __attribute__((weak
));
84 __VLTRegisterPair(void**, const void*, std::size_t,
85 const void*) __attribute__((weak
));
88 __VLTVerifyVtablePointer(void**, const void*) __attribute__((weak
));
91 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
92 void**) __attribute__((weak
));
95 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
96 const char*, const char*) __attribute__((weak
));
99 __VLTVerifyVtablePointerDebug(void**, const void*, const char*,
100 const char*) __attribute__((weak
));
107 __VLTChangePermission(int)
111 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t, void**)
115 __VLTRegisterPair(void**, const void*, std::size_t, const void*)
119 __VLTVerifyVtablePointer(void**, const void* vtable_ptr
)
120 { return vtable_ptr
; }
123 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t, void**)
127 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
128 const char*, const char*)
132 __VLTVerifyVtablePointerDebug(void**, const void* vtable_ptr
, const char*,
134 { return vtable_ptr
; }