blob: eda5ec65eac95a454726233202edd2731dbca665 [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
sewardjb3a1e4b2015-08-21 11:32:26 +000010 Copyright (C) 2000-2015 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
florian535fb1b2013-09-15 13:54:34 +000034#include "pub_core_basics.h" // VG_ macro
35
njna7598f62005-06-18 03:27:58 +000036//--------------------------------------------------------------------
sewardjb9bce632005-06-21 01:41:34 +000037// 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.
sewardja672ea32006-04-29 18:03:14 +000042//
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.
njna7598f62005-06-18 03:27:58 +000051//--------------------------------------------------------------------
52
sewardjb9bce632005-06-21 01:41:34 +000053/* 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
56 invalid addresses. */
njn7d2a9c42005-06-19 21:49:28 +000057
bartbecedea2010-07-29 18:12:23 +000058extern Addr VG_(trampoline_stuff_start);
59extern Addr VG_(trampoline_stuff_end);
njna7598f62005-06-18 03:27:58 +000060
sewardjb9bce632005-06-21 01:41:34 +000061#if defined(VGP_x86_linux)
bartbecedea2010-07-29 18:12:23 +000062extern Addr VG_(x86_linux_SUBST_FOR_sigreturn);
63extern Addr VG_(x86_linux_SUBST_FOR_rt_sigreturn);
sewardj6a443b22005-11-20 19:37:54 +000064extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
sewardjd28cc962011-03-28 08:22:55 +000065extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* );
sewardjb9bce632005-06-21 01:41:34 +000066#endif
njna7598f62005-06-18 03:27:58 +000067
sewardjb9bce632005-06-21 01:41:34 +000068#if defined(VGP_amd64_linux)
bartbecedea2010-07-29 18:12:23 +000069extern Addr VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
70extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday);
71extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
tomd6ae9e62012-02-09 11:54:16 +000072extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
sewardjb57e6932009-08-02 12:21:31 +000073extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
sewardjb9bce632005-06-21 01:41:34 +000074#endif
sewardjad50be32005-08-18 11:54:30 +000075
76#if defined(VGP_ppc32_linux)
bartbecedea2010-07-29 18:12:23 +000077extern Addr VG_(ppc32_linux_SUBST_FOR_sigreturn);
78extern Addr VG_(ppc32_linux_SUBST_FOR_rt_sigreturn);
sewardj31d83422005-10-15 02:00:41 +000079extern UInt VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
80extern UInt VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
81extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
sewardjad50be32005-08-18 11:54:30 +000082#endif
sewardjf0915fc2006-01-05 14:07:04 +000083
carllcae0cc22014-08-07 23:17:29 +000084#if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
bartbecedea2010-07-29 18:12:23 +000085extern Addr VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
sewardjf0915fc2006-01-05 14:07:04 +000086extern UInt VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
sewardj1a85f4f2006-01-12 21:15:35 +000087extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
sewardj658f05a2006-01-17 02:21:09 +000088/* A label (sans dot) marking the ultra-magical return stub via which
89 all redirected and wrapped functions are made to "return" on
sewardj6e9de462011-06-28 07:25:29 +000090 ppc64-linux. The one insn at this label is never really
91 translated. Instead, m_translate generates IR to restore the
92 thread's LR and R2 registers from a small stack in the ppc64 guest
93 state structure, and then branch to LR. Convoluted? Confusing?
94 You betcha. Could I think of anything simpler? No. */
bartbecedea2010-07-29 18:12:23 +000095extern Addr VG_(ppctoc_magic_redirect_return_stub);
sewardjf832bb92006-10-17 01:54:54 +000096#endif
97
sewardj59570ff2010-01-01 11:59:33 +000098#if defined(VGP_arm_linux)
sewardjbc33be62011-11-20 09:35:51 +000099extern Addr VG_(arm_linux_SUBST_FOR_sigreturn);
100extern Addr VG_(arm_linux_SUBST_FOR_rt_sigreturn);
sewardj59570ff2010-01-01 11:59:33 +0000101extern UInt VG_(arm_linux_REDIR_FOR_strlen)( void* );
102//extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
103extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
mjw1cd23782014-08-28 14:59:04 +0000104extern void* VG_(arm_linux_REDIR_FOR_strcmp)( void*, void* );
sewardj59570ff2010-01-01 11:59:33 +0000105#endif
106
sewardj112711a2015-04-10 12:30:09 +0000107#if defined(VGP_tilegx_linux)
108extern Addr VG_(tilegx_linux_SUBST_FOR_rt_sigreturn);
109extern UInt VG_(tilegx_linux_REDIR_FOR_strlen)( void* );
110#endif
111
sewardjf0c12502014-01-12 12:54:00 +0000112#if defined(VGP_arm64_linux)
113extern Addr VG_(arm64_linux_SUBST_FOR_rt_sigreturn);
sewardj7aa66512014-03-09 09:44:32 +0000114extern ULong VG_(arm64_linux_REDIR_FOR_strlen)( void* );
115extern void* VG_(arm64_linux_REDIR_FOR_index) ( void*, Long );
116extern Long VG_(arm64_linux_REDIR_FOR_strcmp)( void*, void* );
sewardjf0c12502014-01-12 12:54:00 +0000117#endif
118
njnea2d6fd2010-07-01 00:20:20 +0000119#if defined(VGP_x86_darwin)
bartbecedea2010-07-29 18:12:23 +0000120extern Addr VG_(x86_darwin_SUBST_FOR_sigreturn);
njnea2d6fd2010-07-01 00:20:20 +0000121extern SizeT VG_(x86_darwin_REDIR_FOR_strlen)( void* );
122extern SizeT VG_(x86_darwin_REDIR_FOR_strcmp)( void*, void* );
123extern void* VG_(x86_darwin_REDIR_FOR_strcat)( void*, void * );
124extern char* VG_(x86_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
125extern SizeT VG_(x86_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
126 SizeT size );
127#endif
128
129#if defined(VGP_amd64_darwin)
bartbecedea2010-07-29 18:12:23 +0000130extern Addr VG_(amd64_darwin_SUBST_FOR_sigreturn);
njnea2d6fd2010-07-01 00:20:20 +0000131extern SizeT VG_(amd64_darwin_REDIR_FOR_strlen)( void* );
132extern SizeT VG_(amd64_darwin_REDIR_FOR_strcmp)( void*, void* );
133extern void* VG_(amd64_darwin_REDIR_FOR_strcat)( void*, void * );
134extern char* VG_(amd64_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
135extern SizeT VG_(amd64_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
136 SizeT size );
137extern UInt VG_(amd64_darwin_REDIR_FOR_arc4random)( void );
sewardj704bf0e2014-06-21 09:34:22 +0000138# if DARWIN_VERS == DARWIN_10_9
139 extern char* VG_(amd64_darwin_REDIR_FOR_strchr)( const char*, int );
140# endif
njnf76d27a2009-05-28 01:53:07 +0000141#endif
142
sewardjb5b87402011-03-07 16:05:35 +0000143#if defined(VGP_s390x_linux)
144extern Addr VG_(s390x_linux_SUBST_FOR_sigreturn);
145extern Addr VG_(s390x_linux_SUBST_FOR_rt_sigreturn);
florianae6e3ac2014-09-03 16:01:10 +0000146// Note: Long for the 2nd parameter because according to z-series ABI,
147// section "Parameter Passing" SIMPLE_ARG:
148// "Values shorter than 64 bits are sign- or zero-extended
149// (as appropriate) to 64 bits."
150extern void* VG_(s390x_linux_REDIR_FOR_index) ( void*, Long );
sewardjb5b87402011-03-07 16:05:35 +0000151#endif
152
sewardj5db15402012-06-07 09:13:21 +0000153#if defined(VGP_mips32_linux)
154extern Addr VG_(mips32_linux_SUBST_FOR_sigreturn);
155extern Addr VG_(mips32_linux_SUBST_FOR_rt_sigreturn);
156extern UInt VG_(mips32_linux_REDIR_FOR_strlen)( void* );
157#endif
158
petarj4df0bfc2013-02-27 23:17:33 +0000159#if defined(VGP_mips64_linux)
160extern Addr VG_(mips64_linux_SUBST_FOR_rt_sigreturn);
161extern UInt VG_(mips64_linux_REDIR_FOR_strlen)( void* );
162#endif
163
sewardj8eb8bab2015-07-21 14:44:28 +0000164#if defined(VGP_x86_solaris)
165extern SizeT VG_(x86_solaris_REDIR_FOR_strcmp)(const HChar *, const HChar *);
166extern SizeT VG_(x86_solaris_REDIR_FOR_strlen)(const HChar *);
167#endif
168
169#if defined(VGP_amd64_solaris)
170extern HChar *VG_(amd64_solaris_REDIR_FOR_strcpy)(HChar *, const HChar *);
171extern HChar *VG_(amd64_solaris_REDIR_FOR_strncpy)(HChar *, const HChar *,
172 SizeT);
173extern Int VG_(amd64_solaris_REDIR_FOR_strcmp)(const HChar *, const HChar *);
174extern HChar *VG_(amd64_solaris_REDIR_FOR_strcat)(HChar *, const HChar *);
175extern SizeT VG_(amd64_solaris_REDIR_FOR_strlen)(const HChar *);
176#endif
177
njna7598f62005-06-18 03:27:58 +0000178#endif // __PUB_CORE_TRAMPOLINE_H
179
180/*--------------------------------------------------------------------*/
181/*--- end ---*/
182/*--------------------------------------------------------------------*/