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-2010 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 //--------------------------------------------------------------------
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
56 extern Addr VG_(trampoline_stuff_start);
57 extern Addr VG_(trampoline_stuff_end);
59 #if defined(VGP_x86_linux)
60 extern Addr VG_(x86_linux_SUBST_FOR_sigreturn);
61 extern Addr VG_(x86_linux_SUBST_FOR_rt_sigreturn);
62 extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
63 extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* );
66 #if defined(VGP_amd64_linux)
67 extern Addr VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
68 extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday);
69 extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
70 extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
73 #if defined(VGP_ppc32_linux)
74 extern Addr VG_(ppc32_linux_SUBST_FOR_sigreturn);
75 extern Addr VG_(ppc32_linux_SUBST_FOR_rt_sigreturn);
76 extern UInt VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
77 extern UInt VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
78 extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
81 #if defined(VGP_ppc64_linux)
82 extern Addr VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
83 extern UInt VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
84 extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
85 /* A label (sans dot) marking the ultra-magical return stub via which
86 all redirected and wrapped functions are made to "return" on
87 ppc64-linux/ppc64-aix5/ppc32-aix5. The one insn at this label is
88 never really translated. Instead, m_translate generates IR to
89 restore the thread's LR and R2 registers from a small stack in the
90 ppc64 guest state structure, and then branch to LR. Convoluted?
91 Confusing? You betcha. Could I think of anything simpler? No. */
92 extern Addr VG_(ppctoc_magic_redirect_return_stub);
95 #if defined(VGP_arm_linux)
96 extern UInt VG_(arm_linux_REDIR_FOR_strlen)( void* );
97 //extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
98 extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
101 #if defined(VGP_ppc32_aix5)
102 /* A label (sans dot) marking the client start point for ppc32_aix5.
103 This function is entered with r3 holding a pointer to the
104 AIX5PreloadPage struct set up by m_initimg. It first tries to
105 __loadx the _core.so and _tool.so preloads mentioned in the struct;
106 then it cleans up the register state to be more what it really
107 should be at client startup, and finally it jumps to the client's
109 extern Addr VG_(ppc32_aix5_do_preloads_then_start_client);
111 /* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
112 extern Addr VG_(ppctoc_magic_redirect_return_stub);
115 #if defined(VGP_ppc64_aix5)
116 /* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
117 extern Addr VG_(ppctoc_magic_redirect_return_stub);
119 /* See comment for ppc32_aix5 equivalent above. */
120 extern Addr VG_(ppc64_aix5_do_preloads_then_start_client);
123 #if defined(VGP_x86_darwin)
124 extern Addr VG_(x86_darwin_SUBST_FOR_sigreturn);
125 extern SizeT VG_(x86_darwin_REDIR_FOR_strlen)( void* );
126 extern SizeT VG_(x86_darwin_REDIR_FOR_strcmp)( void*, void* );
127 extern void* VG_(x86_darwin_REDIR_FOR_strcat)( void*, void * );
128 extern char* VG_(x86_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
129 extern SizeT VG_(x86_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
133 #if defined(VGP_amd64_darwin)
134 extern Addr VG_(amd64_darwin_SUBST_FOR_sigreturn);
135 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlen)( void* );
136 extern SizeT VG_(amd64_darwin_REDIR_FOR_strcmp)( void*, void* );
137 extern void* VG_(amd64_darwin_REDIR_FOR_strcat)( void*, void * );
138 extern char* VG_(amd64_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
139 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
141 extern UInt VG_(amd64_darwin_REDIR_FOR_arc4random)( void );
144 #if defined(VGO_l4re)
145 extern void VG_(x86_l4re_SUBST_FOR_sigreturn);
146 extern void VG_(x86_l4re_SUBST_FOR_rt_sigreturn);
147 extern Char* VG_(x86_l4re_REDIR_FOR_index) ( const Char*, Int );
148 extern void VG_(x86_l4re_REDIR_FOR_syscall_page)(void);
150 extern void VG_(l4re_trampoline_stuff_start);
151 extern void VG_(l4re_trampoline_stuff_end);
154 #if defined(VGP_s390x_linux)
155 extern Addr VG_(s390x_linux_SUBST_FOR_sigreturn);
156 extern Addr VG_(s390x_linux_SUBST_FOR_rt_sigreturn);
159 #endif // __PUB_CORE_TRAMPOLINE_H
161 /*--------------------------------------------------------------------*/
163 /*--------------------------------------------------------------------*/