blob: aee983c1b70e912fdc0a3bb81db4cb99734b172a [file] [log] [blame]
njna7598f62005-06-18 03:27:58 +00001
2/*--------------------------------------------------------------------*/
3/*--- The trampoline code page. pub_core_trampoline.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj9eecbbb2010-05-03 21:37:12 +000010 Copyright (C) 2000-2010 Julian Seward
njna7598f62005-06-18 03:27:58 +000011 jseward@acm.org
12
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.
17
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.
22
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
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_CORE_TRAMPOLINE_H
32#define __PUB_CORE_TRAMPOLINE_H
33
34//--------------------------------------------------------------------
sewardjb9bce632005-06-21 01:41:34 +000035// 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.
sewardja672ea32006-04-29 18:03:14 +000040//
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.
njna7598f62005-06-18 03:27:58 +000049//--------------------------------------------------------------------
50
sewardjb9bce632005-06-21 01:41:34 +000051/* 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. */
njn7d2a9c42005-06-19 21:49:28 +000055
bartbecedea2010-07-29 18:12:23 +000056extern Addr VG_(trampoline_stuff_start);
57extern Addr VG_(trampoline_stuff_end);
njna7598f62005-06-18 03:27:58 +000058
sewardjb9bce632005-06-21 01:41:34 +000059#if defined(VGP_x86_linux)
bartbecedea2010-07-29 18:12:23 +000060extern Addr VG_(x86_linux_SUBST_FOR_sigreturn);
61extern Addr VG_(x86_linux_SUBST_FOR_rt_sigreturn);
sewardj6a443b22005-11-20 19:37:54 +000062extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
sewardjd28cc962011-03-28 08:22:55 +000063extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* );
sewardjb9bce632005-06-21 01:41:34 +000064#endif
njna7598f62005-06-18 03:27:58 +000065
sewardjb9bce632005-06-21 01:41:34 +000066#if defined(VGP_amd64_linux)
bartbecedea2010-07-29 18:12:23 +000067extern Addr VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
68extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday);
69extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
sewardjb57e6932009-08-02 12:21:31 +000070extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
sewardjb9bce632005-06-21 01:41:34 +000071#endif
sewardjad50be32005-08-18 11:54:30 +000072
73#if defined(VGP_ppc32_linux)
bartbecedea2010-07-29 18:12:23 +000074extern Addr VG_(ppc32_linux_SUBST_FOR_sigreturn);
75extern Addr VG_(ppc32_linux_SUBST_FOR_rt_sigreturn);
sewardj31d83422005-10-15 02:00:41 +000076extern UInt VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
77extern UInt VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
78extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
sewardjad50be32005-08-18 11:54:30 +000079#endif
sewardjf0915fc2006-01-05 14:07:04 +000080
81#if defined(VGP_ppc64_linux)
bartbecedea2010-07-29 18:12:23 +000082extern Addr VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
sewardjf0915fc2006-01-05 14:07:04 +000083extern UInt VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
sewardj1a85f4f2006-01-12 21:15:35 +000084extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
sewardj658f05a2006-01-17 02:21:09 +000085/* A label (sans dot) marking the ultra-magical return stub via which
86 all redirected and wrapped functions are made to "return" on
sewardjf832bb92006-10-17 01:54:54 +000087 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. */
bartbecedea2010-07-29 18:12:23 +000092extern Addr VG_(ppctoc_magic_redirect_return_stub);
sewardjf832bb92006-10-17 01:54:54 +000093#endif
94
sewardj59570ff2010-01-01 11:59:33 +000095#if defined(VGP_arm_linux)
96extern UInt VG_(arm_linux_REDIR_FOR_strlen)( void* );
97//extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
98extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
99#endif
100
sewardjf832bb92006-10-17 01:54:54 +0000101#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
108 real entry point. */
bartbecedea2010-07-29 18:12:23 +0000109extern Addr VG_(ppc32_aix5_do_preloads_then_start_client);
sewardjf832bb92006-10-17 01:54:54 +0000110
111/* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
bartbecedea2010-07-29 18:12:23 +0000112extern Addr VG_(ppctoc_magic_redirect_return_stub);
sewardjf832bb92006-10-17 01:54:54 +0000113#endif
114
115#if defined(VGP_ppc64_aix5)
116/* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
bartbecedea2010-07-29 18:12:23 +0000117extern Addr VG_(ppctoc_magic_redirect_return_stub);
sewardjf832bb92006-10-17 01:54:54 +0000118
119/* See comment for ppc32_aix5 equivalent above. */
bartbecedea2010-07-29 18:12:23 +0000120extern Addr VG_(ppc64_aix5_do_preloads_then_start_client);
sewardjf0915fc2006-01-05 14:07:04 +0000121#endif
njncda2f0f2009-05-18 02:12:08 +0000122
njnea2d6fd2010-07-01 00:20:20 +0000123#if defined(VGP_x86_darwin)
bartbecedea2010-07-29 18:12:23 +0000124extern Addr VG_(x86_darwin_SUBST_FOR_sigreturn);
njnea2d6fd2010-07-01 00:20:20 +0000125extern SizeT VG_(x86_darwin_REDIR_FOR_strlen)( void* );
126extern SizeT VG_(x86_darwin_REDIR_FOR_strcmp)( void*, void* );
127extern void* VG_(x86_darwin_REDIR_FOR_strcat)( void*, void * );
128extern char* VG_(x86_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
129extern SizeT VG_(x86_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
130 SizeT size );
131#endif
132
133#if defined(VGP_amd64_darwin)
bartbecedea2010-07-29 18:12:23 +0000134extern Addr VG_(amd64_darwin_SUBST_FOR_sigreturn);
njnea2d6fd2010-07-01 00:20:20 +0000135extern SizeT VG_(amd64_darwin_REDIR_FOR_strlen)( void* );
136extern SizeT VG_(amd64_darwin_REDIR_FOR_strcmp)( void*, void* );
137extern void* VG_(amd64_darwin_REDIR_FOR_strcat)( void*, void * );
138extern char* VG_(amd64_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
139extern SizeT VG_(amd64_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
140 SizeT size );
141extern UInt VG_(amd64_darwin_REDIR_FOR_arc4random)( void );
njnf76d27a2009-05-28 01:53:07 +0000142#endif
143
sewardjb5b87402011-03-07 16:05:35 +0000144#if defined(VGP_s390x_linux)
145extern Addr VG_(s390x_linux_SUBST_FOR_sigreturn);
146extern Addr VG_(s390x_linux_SUBST_FOR_rt_sigreturn);
147#endif
148
njna7598f62005-06-18 03:27:58 +0000149#endif // __PUB_CORE_TRAMPOLINE_H
150
151/*--------------------------------------------------------------------*/
152/*--- end ---*/
153/*--------------------------------------------------------------------*/