2 /*--------------------------------------------------------------------*/
3 /*--- The trampoline code page. pub_core_trampoline.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2017 Julian Seward
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, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
31 #ifndef __PUB_CORE_TRAMPOLINE_H
32 #define __PUB_CORE_TRAMPOLINE_H
34 #include "pub_core_basics.h" // VG_ macro
36 //--------------------------------------------------------------------
37 // PURPOSE: This module defines a few replacement functions for Linux
38 // vsyscalls, which we can't implement directly. It also contains
39 // stubs for signal returns. Note, all the code within runs on the
40 // simulated CPU. The vsyscall stubs are gotten to by use of the
41 // redirect mechanism.
43 // Note: generally, putting replacement functions in here is a bad
44 // idea, since any Dwarf frame-unwind info attached to them will not
45 // be seen by the unwinder in gcc's runtime support. This means
46 // unwinding during exception handling by gcc tends to fail if it
47 // encounters one of these replacement functions. A better place to
48 // put them is in one of the .so's preloaded into the client, since
49 // the client's ld.so will know about it and so gcc's unwinder
50 // (somehow) is able to get hold of it.
51 //--------------------------------------------------------------------
53 /* These two delimit our handwritten assembly code, so we can tell
54 tools which track memory that this area should be regarded as
55 readable, at least. Otherwise Memcheck complains we're jumping to
58 extern Addr
VG_(trampoline_stuff_start
);
59 extern Addr
VG_(trampoline_stuff_end
);
61 #if defined(VGP_x86_linux)
62 extern Addr
VG_(x86_linux_SUBST_FOR_sigreturn
);
63 extern Addr
VG_(x86_linux_SUBST_FOR_rt_sigreturn
);
64 extern Char
* VG_(x86_linux_REDIR_FOR_index
) ( const Char
*, Int
);
65 extern UInt
VG_(x86_linux_REDIR_FOR_strlen
)( void* );
68 #if defined(VGP_amd64_linux)
69 extern Addr
VG_(amd64_linux_SUBST_FOR_rt_sigreturn
);
70 extern Addr
VG_(amd64_linux_REDIR_FOR_vgettimeofday
);
71 extern Addr
VG_(amd64_linux_REDIR_FOR_vtime
);
72 extern Addr
VG_(amd64_linux_REDIR_FOR_vgetcpu
);
73 extern UInt
VG_(amd64_linux_REDIR_FOR_strlen
)( void* );
74 extern Char
* VG_(amd64_linux_REDIR_FOR_index
) ( const Char
*, Int
);
77 #if defined(VGP_ppc32_linux)
78 extern Addr
VG_(ppc32_linux_SUBST_FOR_sigreturn
);
79 extern Addr
VG_(ppc32_linux_SUBST_FOR_rt_sigreturn
);
80 extern UInt
VG_(ppc32_linux_REDIR_FOR_strlen
)( void* );
81 extern UInt
VG_(ppc32_linux_REDIR_FOR_strcmp
)( void*, void* );
82 extern void* VG_(ppc32_linux_REDIR_FOR_strchr
)( void*, Int
);
85 #if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
86 extern Addr
VG_(ppc64_linux_SUBST_FOR_rt_sigreturn
);
87 extern UInt
VG_(ppc64_linux_REDIR_FOR_strlen
)( void* );
88 extern void* VG_(ppc64_linux_REDIR_FOR_strchr
)( void*, Int
);
89 /* A label (sans dot) marking the ultra-magical return stub via which
90 all redirected and wrapped functions are made to "return" on
91 ppc64-linux. The one insn at this label is never really
92 translated. Instead, m_translate generates IR to restore the
93 thread's LR and R2 registers from a small stack in the ppc64 guest
94 state structure, and then branch to LR. Convoluted? Confusing?
95 You betcha. Could I think of anything simpler? No. */
96 extern Addr
VG_(ppctoc_magic_redirect_return_stub
);
99 #if defined(VGP_arm_linux)
100 extern Addr
VG_(arm_linux_SUBST_FOR_sigreturn
);
101 extern Addr
VG_(arm_linux_SUBST_FOR_rt_sigreturn
);
102 extern UInt
VG_(arm_linux_REDIR_FOR_strlen
)( void* );
103 extern void* VG_(arm_linux_REDIR_FOR_index
) ( void*, Int
);
104 extern void* VG_(arm_linux_REDIR_FOR_memcpy
)( void*, void*, Int
);
105 extern void* VG_(arm_linux_REDIR_FOR_strcmp
)( void*, void* );
108 #if defined(VGP_arm64_linux)
109 extern Addr
VG_(arm64_linux_SUBST_FOR_rt_sigreturn
);
110 extern ULong
VG_(arm64_linux_REDIR_FOR_strlen
)( void* );
111 extern void* VG_(arm64_linux_REDIR_FOR_index
) ( void*, Long
);
112 extern Long
VG_(arm64_linux_REDIR_FOR_strcmp
)( void*, void* );
115 #if defined(VGP_x86_darwin)
116 extern Addr
VG_(x86_darwin_SUBST_FOR_sigreturn
);
117 extern SizeT
VG_(x86_darwin_REDIR_FOR_strlen
)( void* );
118 extern SizeT
VG_(x86_darwin_REDIR_FOR_strcmp
)( void*, void* );
119 extern void* VG_(x86_darwin_REDIR_FOR_strcat
)( void*, void * );
120 extern char* VG_(x86_darwin_REDIR_FOR_strcpy
)( char *s1
, char *s2
);
121 extern SizeT
VG_(x86_darwin_REDIR_FOR_strlcat
)( char *s1
, const char *s2
,
125 #if defined(VGP_amd64_darwin)
126 extern Addr
VG_(amd64_darwin_SUBST_FOR_sigreturn
);
127 extern SizeT
VG_(amd64_darwin_REDIR_FOR_strlen
)( void* );
128 extern SizeT
VG_(amd64_darwin_REDIR_FOR_strcmp
)( void*, void* );
129 extern void* VG_(amd64_darwin_REDIR_FOR_strcat
)( void*, void * );
130 extern char* VG_(amd64_darwin_REDIR_FOR_strcpy
)( char *s1
, char *s2
);
131 extern SizeT
VG_(amd64_darwin_REDIR_FOR_strlcat
)( char *s1
, const char *s2
,
133 extern UInt
VG_(amd64_darwin_REDIR_FOR_arc4random
)( void );
134 # if DARWIN_VERS == DARWIN_10_9
135 extern char* VG_(amd64_darwin_REDIR_FOR_strchr
)( const char*, int );
139 #if defined(VGP_s390x_linux)
140 extern Addr
VG_(s390x_linux_SUBST_FOR_sigreturn
);
141 extern Addr
VG_(s390x_linux_SUBST_FOR_rt_sigreturn
);
142 // Note: Long for the 2nd parameter because according to z-series ABI,
143 // section "Parameter Passing" SIMPLE_ARG:
144 // "Values shorter than 64 bits are sign- or zero-extended
145 // (as appropriate) to 64 bits."
146 extern void* VG_(s390x_linux_REDIR_FOR_index
) ( void*, Long
);
149 #if defined(VGP_mips32_linux)
150 extern Addr
VG_(mips32_linux_SUBST_FOR_sigreturn
);
151 extern Addr
VG_(mips32_linux_SUBST_FOR_rt_sigreturn
);
152 extern Char
* VG_(mips32_linux_REDIR_FOR_index
)( const Char
*, Int
);
153 extern UInt
VG_(mips32_linux_REDIR_FOR_strlen
)( void* );
156 #if defined(VGP_mips64_linux)
157 extern Addr
VG_(mips64_linux_SUBST_FOR_rt_sigreturn
);
158 extern Char
* VG_(mips64_linux_REDIR_FOR_index
)( const Char
*, Int
);
159 extern UInt
VG_(mips64_linux_REDIR_FOR_strlen
)( void* );
162 #if defined(VGP_x86_solaris)
163 extern SizeT
VG_(x86_solaris_REDIR_FOR_strcmp
)(const HChar
*, const HChar
*);
164 extern SizeT
VG_(x86_solaris_REDIR_FOR_strlen
)(const HChar
*);
167 #if defined(VGP_amd64_solaris)
168 extern HChar
*VG_(amd64_solaris_REDIR_FOR_strcpy
)(HChar
*, const HChar
*);
169 extern HChar
*VG_(amd64_solaris_REDIR_FOR_strncpy
)(HChar
*, const HChar
*,
171 extern Int
VG_(amd64_solaris_REDIR_FOR_strcmp
)(const HChar
*, const HChar
*);
172 extern HChar
*VG_(amd64_solaris_REDIR_FOR_strcat
)(HChar
*, const HChar
*);
173 extern SizeT
VG_(amd64_solaris_REDIR_FOR_strlen
)(const HChar
*);
176 #endif // __PUB_CORE_TRAMPOLINE_H
178 /*--------------------------------------------------------------------*/
180 /*--------------------------------------------------------------------*/