1 // Copyright (C) 2012-2014 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.
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 
40 // Declare as weak for libsupc++, strong definitions are in libvtv.
41 #if __GXX_WEAK__
42 extern "C"
43 void
44 __VLTChangePermission(int) __attribute__((weak));
45 
46 void
47 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t,
48 		 void**) __attribute__((weak));
49 
50 void
51 __VLTRegisterPair(void**, const void*, std::size_t,
52 		  const void*) __attribute__((weak));
53 
54 const void*
55 __VLTVerifyVtablePointer(void**, const void*) __attribute__((weak));
56 
57 void
58 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t,
59 		      void**) __attribute__((weak));
60 
61 void
62 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
63 		       const char*, const char*) __attribute__((weak));
64 
65 const void*
66 __VLTVerifyVtablePointerDebug(void**, const void*, const char*,
67 			      const char*) __attribute__((weak));
68 #endif
69 
70 // Stub definitions.
71 extern "C"
72 void
__VLTChangePermission(int)73 __VLTChangePermission(int)
74 { }
75 
76 void
__VLTRegisterSet(void **,const void *,std::size_t,std::size_t,void **)77 __VLTRegisterSet(void**, const void*, std::size_t, std::size_t, void**)
78 { }
79 
80 void
__VLTRegisterPair(void **,const void *,std::size_t,const void *)81 __VLTRegisterPair(void**, const void*, std::size_t, const void*)
82 { }
83 
84 const void*
__VLTVerifyVtablePointer(void **,const void * vtable_ptr)85 __VLTVerifyVtablePointer(void**, const void* vtable_ptr)
86 { return vtable_ptr; }
87 
88 void
__VLTRegisterSetDebug(void **,const void *,std::size_t,std::size_t,void **)89 __VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t, void**)
90 { }
91 
92 void
__VLTRegisterPairDebug(void **,const void *,std::size_t,const void *,const char *,const char *)93 __VLTRegisterPairDebug(void**, const void*, std::size_t, const void*,
94 		       const char*, const  char*)
95 { }
96 
97 const void*
__VLTVerifyVtablePointerDebug(void **,const void * vtable_ptr,const char *,const char *)98 __VLTVerifyVtablePointerDebug(void**, const void* vtable_ptr, const char*,
99 			      const char*)
100 { return vtable_ptr; }
101