syswrap openat2 for all linux arches
[valgrind.git] / coregrind / pub_core_trampoline.h
blob54c575a7233a9451aca8acc03f370ceeb29182fc
2 /*--------------------------------------------------------------------*/
3 /*--- The trampoline code page. pub_core_trampoline.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2000-2017 Julian Seward
11 jseward@acm.org
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_CORE_TRAMPOLINE_H
30 #define __PUB_CORE_TRAMPOLINE_H
32 #include "pub_core_basics.h" // VG_ macro
34 //--------------------------------------------------------------------
35 // PURPOSE: This module defines a few replacement functions for Linux
36 // vsyscalls, which we can't implement directly. It also contains
37 // stubs for signal returns. Note, all the code within runs on the
38 // simulated CPU. The vsyscall stubs are gotten to by use of the
39 // redirect mechanism.
41 // Note: generally, putting replacement functions in here is a bad
42 // idea, since any Dwarf frame-unwind info attached to them will not
43 // be seen by the unwinder in gcc's runtime support. This means
44 // unwinding during exception handling by gcc tends to fail if it
45 // encounters one of these replacement functions. A better place to
46 // put them is in one of the .so's preloaded into the client, since
47 // the client's ld.so will know about it and so gcc's unwinder
48 // (somehow) is able to get hold of it.
49 //--------------------------------------------------------------------
51 /* These two delimit our handwritten assembly code, so we can tell
52 tools which track memory that this area should be regarded as
53 readable, at least. Otherwise Memcheck complains we're jumping to
54 invalid addresses. */
56 extern Addr VG_(trampoline_stuff_start);
57 extern Addr VG_(trampoline_stuff_end);
59 #if defined(VGP_x86_freebsd)
60 extern void VG_(x86_freebsd_SUBST_FOR_sigreturn);
61 #endif
63 #if defined(VGP_amd64_freebsd)
64 extern void VG_(amd64_freebsd_SUBST_FOR_sigreturn);
65 #endif
67 #if defined(VGP_x86_linux)
68 extern Addr VG_(x86_linux_SUBST_FOR_sigreturn);
69 extern Addr VG_(x86_linux_SUBST_FOR_rt_sigreturn);
70 extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
71 extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* );
72 #endif
74 #if defined(VGP_amd64_linux)
75 extern Addr VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
76 extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday);
77 extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
78 extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
79 extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
80 extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
81 #endif
83 #if defined(VGP_ppc32_linux)
84 extern Addr VG_(ppc32_linux_SUBST_FOR_sigreturn);
85 extern Addr VG_(ppc32_linux_SUBST_FOR_rt_sigreturn);
86 extern UInt VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
87 extern UInt VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
88 extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
89 #endif
91 #if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
92 extern Addr VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
93 extern UInt VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
94 extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
95 /* A label (sans dot) marking the ultra-magical return stub via which
96 all redirected and wrapped functions are made to "return" on
97 ppc64-linux. The one insn at this label is never really
98 translated. Instead, m_translate generates IR to restore the
99 thread's LR and R2 registers from a small stack in the ppc64 guest
100 state structure, and then branch to LR. Convoluted? Confusing?
101 You betcha. Could I think of anything simpler? No. */
102 extern Addr VG_(ppctoc_magic_redirect_return_stub);
103 #endif
105 #if defined(VGP_arm_linux)
106 extern Addr VG_(arm_linux_SUBST_FOR_sigreturn);
107 extern Addr VG_(arm_linux_SUBST_FOR_rt_sigreturn);
108 extern UInt VG_(arm_linux_REDIR_FOR_strlen)( void* );
109 extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
110 extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
111 extern void* VG_(arm_linux_REDIR_FOR_strcmp)( void*, void* );
112 #endif
114 #if defined(VGP_arm64_linux)
115 extern Addr VG_(arm64_linux_SUBST_FOR_rt_sigreturn);
116 extern ULong VG_(arm64_linux_REDIR_FOR_strlen)( void* );
117 extern void* VG_(arm64_linux_REDIR_FOR_index) ( void*, Long );
118 extern Long VG_(arm64_linux_REDIR_FOR_strcmp)( void*, void* );
119 #endif
121 #if defined(VGP_x86_darwin)
122 extern Addr VG_(x86_darwin_SUBST_FOR_sigreturn);
123 extern SizeT VG_(x86_darwin_REDIR_FOR_strlen)( void* );
124 extern SizeT VG_(x86_darwin_REDIR_FOR_strcmp)( void*, void* );
125 extern void* VG_(x86_darwin_REDIR_FOR_strcat)( void*, void * );
126 extern char* VG_(x86_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
127 extern SizeT VG_(x86_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
128 SizeT size );
129 #endif
131 #if defined(VGP_amd64_darwin)
132 extern Addr VG_(amd64_darwin_SUBST_FOR_sigreturn);
133 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlen)( void* );
134 extern SizeT VG_(amd64_darwin_REDIR_FOR_strcmp)( void*, void* );
135 extern void* VG_(amd64_darwin_REDIR_FOR_strcat)( void*, void * );
136 extern char* VG_(amd64_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
137 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
138 SizeT size );
139 extern UInt VG_(amd64_darwin_REDIR_FOR_arc4random)( void );
140 # if DARWIN_VERS == DARWIN_10_9
141 extern char* VG_(amd64_darwin_REDIR_FOR_strchr)( const char*, int );
142 # endif
143 #endif
145 #if defined(VGP_s390x_linux)
146 extern Addr VG_(s390x_linux_SUBST_FOR_sigreturn);
147 extern Addr VG_(s390x_linux_SUBST_FOR_rt_sigreturn);
148 // Note: Long for the 2nd parameter because according to z-series ABI,
149 // section "Parameter Passing" SIMPLE_ARG:
150 // "Values shorter than 64 bits are sign- or zero-extended
151 // (as appropriate) to 64 bits."
152 extern void* VG_(s390x_linux_REDIR_FOR_index) ( void*, Long );
153 #endif
155 #if defined(VGP_mips32_linux)
156 extern Addr VG_(mips32_linux_SUBST_FOR_sigreturn);
157 extern Addr VG_(mips32_linux_SUBST_FOR_rt_sigreturn);
158 extern Char* VG_(mips32_linux_REDIR_FOR_index)( const Char*, Int );
159 extern UInt VG_(mips32_linux_REDIR_FOR_strlen)( void* );
160 #endif
162 #if defined(VGP_mips64_linux)
163 extern Addr VG_(mips64_linux_SUBST_FOR_rt_sigreturn);
164 extern Char* VG_(mips64_linux_REDIR_FOR_index)( const Char*, Int );
165 extern UInt VG_(mips64_linux_REDIR_FOR_strlen)( void* );
166 #endif
168 #if defined(VGP_nanomips_linux)
169 extern Addr VG_(nanomips_linux_SUBST_FOR_rt_sigreturn);
170 extern Char* VG_(nanomips_linux_REDIR_FOR_index)( const Char*, Int );
171 extern UInt VG_(nanomips_linux_REDIR_FOR_strlen)( void* );
172 #endif
174 #if defined(VGP_x86_solaris)
175 extern SizeT VG_(x86_solaris_REDIR_FOR_strcmp)(const HChar *, const HChar *);
176 extern SizeT VG_(x86_solaris_REDIR_FOR_strlen)(const HChar *);
177 #endif
179 #if defined(VGP_amd64_solaris)
180 extern HChar *VG_(amd64_solaris_REDIR_FOR_strcpy)(HChar *, const HChar *);
181 extern HChar *VG_(amd64_solaris_REDIR_FOR_strncpy)(HChar *, const HChar *,
182 SizeT);
183 extern Int VG_(amd64_solaris_REDIR_FOR_strcmp)(const HChar *, const HChar *);
184 extern HChar *VG_(amd64_solaris_REDIR_FOR_strcat)(HChar *, const HChar *);
185 extern SizeT VG_(amd64_solaris_REDIR_FOR_strlen)(const HChar *);
186 #endif
188 #endif // __PUB_CORE_TRAMPOLINE_H
190 /*--------------------------------------------------------------------*/
191 /*--- end ---*/
192 /*--------------------------------------------------------------------*/