blob: f2484472631441f9045b11e6418693a05fd8a344 [file] [log] [blame]
njna7598f62005-06-18 03:27:58 +00001
sewardjb9bce632005-06-21 01:41:34 +00002/*--------------------------------------------------------------------*/
3/*--- Trampoline code page stuff. m_trampoline.S ---*/
4/*--------------------------------------------------------------------*/
sewardjde4a1d02002-03-22 01:27:54 +00005
6/*
njnb9c427c2004-12-01 14:14:42 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjde4a1d02002-03-22 01:27:54 +00009
njn53612422005-03-12 16:22:54 +000010 Copyright (C) 2000-2005 Julian Seward
sewardjde4a1d02002-03-22 01:27:54 +000011 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000012
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
njn25e49d8e72002-09-23 09:36:25 +000028 The GNU General Public License is contained in the file COPYING.
sewardjde4a1d02002-03-22 01:27:54 +000029*/
30
njnc7561b92005-06-19 01:24:32 +000031#include "pub_tool_basics_asm.h"
sewardjb5f6f512005-03-10 23:59:00 +000032#include "vki_unistd.h"
sewardjde4a1d02002-03-22 01:27:54 +000033
sewardj54cacf02002-04-12 23:24:59 +000034/* ------------------ SIMULATED CPU HELPERS ------------------ */
sewardjb9bce632005-06-21 01:41:34 +000035/*
36 Replacements for some functions to do with vsyscalls and signals.
37 This code runs on the simulated CPU.
sewardj54cacf02002-04-12 23:24:59 +000038*/
sewardjb9bce632005-06-21 01:41:34 +000039
sewardj05b5fc12005-06-21 09:56:56 +000040/*---------------- x86-linux ----------------*/
njna7598f62005-06-18 03:27:58 +000041#if defined(VGP_x86_linux)
sewardjb9bce632005-06-21 01:41:34 +000042
43.global VG_(trampoline_stuff_start)
44VG_(trampoline_stuff_start):
45
46.global VG_(x86_linux_SUBST_FOR_sigreturn)
47VG_(x86_linux_SUBST_FOR_sigreturn):
sewardjb5f6f512005-03-10 23:59:00 +000048 /* This is a very specific sequence which GDB uses to
49 recognize signal handler frames. */
50 popl %eax
51 movl $__NR_sigreturn, %eax
52 int $0x80
53 ud2
54
sewardjb9bce632005-06-21 01:41:34 +000055.global VG_(x86_linux_SUBST_FOR_rt_sigreturn)
56VG_(x86_linux_SUBST_FOR_rt_sigreturn):
sewardjb5f6f512005-03-10 23:59:00 +000057 /* Likewise for rt signal frames */
58 movl $__NR_rt_sigreturn, %eax
59 int $0x80
60 ud2
fitzhardinge98abfc72003-12-16 02:05:15 +000061
sewardjb9bce632005-06-21 01:41:34 +000062.global VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80)
63VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80):
64 /* We can point our sysinfo stuff here */
fitzhardinge92360792003-12-24 10:11:11 +000065 int $0x80
66 ret
sewardjb9bce632005-06-21 01:41:34 +000067
68.global VG_(trampoline_stuff_end)
69VG_(trampoline_stuff_end):
njna7598f62005-06-18 03:27:58 +000070
sewardjb9bce632005-06-21 01:41:34 +000071
sewardj05b5fc12005-06-21 09:56:56 +000072/*---------------- amd64-linux ----------------*/
sewardjb9bce632005-06-21 01:41:34 +000073#else
74#if defined(VGP_amd64_linux)
njna7598f62005-06-18 03:27:58 +000075
sewardjb9bce632005-06-21 01:41:34 +000076.global VG_(trampoline_stuff_start)
77VG_(trampoline_stuff_start):
78
79.global VG_(amd64_linux_SUBST_FOR_rt_sigreturn)
80VG_(amd64_linux_SUBST_FOR_rt_sigreturn):
81 /* This is a very specific sequence which GDB uses to
82 recognize signal handler frames. */
njna7598f62005-06-18 03:27:58 +000083 movq $__NR_rt_sigreturn, %rax
84 syscall
85 ud2
86
sewardjb9bce632005-06-21 01:41:34 +000087.global VG_(amd64_linux_REDIR_FOR_vgettimeofday)
88VG_(amd64_linux_REDIR_FOR_vgettimeofday):
njna7598f62005-06-18 03:27:58 +000089 movq $__NR_gettimeofday, %rax
90 syscall
91 ret
92
sewardjb9bce632005-06-21 01:41:34 +000093.global VG_(amd64_linux_REDIR_FOR_vtime)
94VG_(amd64_linux_REDIR_FOR_vtime):
njna7598f62005-06-18 03:27:58 +000095 movq $__NR_time, %rax
96 syscall
97 ret
98
sewardjb9bce632005-06-21 01:41:34 +000099.global VG_(trampoline_stuff_end)
100VG_(trampoline_stuff_end):
njna7598f62005-06-18 03:27:58 +0000101
sewardjb9bce632005-06-21 01:41:34 +0000102
sewardj05b5fc12005-06-21 09:56:56 +0000103/*---------------- ppc32-linux ----------------*/
sewardjb9bce632005-06-21 01:41:34 +0000104#else
105#if defined(VGP_ppc32_linux)
106
sewardj05b5fc12005-06-21 09:56:56 +0000107.global VG_(trampoline_stuff_start)
108VG_(trampoline_stuff_start):
cerion85665ca2005-06-20 15:51:07 +0000109
sewardj05b5fc12005-06-21 09:56:56 +0000110.global VG_(trampoline_stuff_end)
111VG_(trampoline_stuff_end):
112
113
114
115/*---------------- unknown ----------------*/
njna7598f62005-06-18 03:27:58 +0000116#else
sewardjb9bce632005-06-21 01:41:34 +0000117# error Unknown platform
118
njna7598f62005-06-18 03:27:58 +0000119#endif
sewardjb9bce632005-06-21 01:41:34 +0000120#endif
121#endif
122
fitzhardinge92360792003-12-24 10:11:11 +0000123tramp_code_end:
sewardjbc5b99f2002-04-13 00:08:51 +0000124
sewardjde4a1d02002-03-22 01:27:54 +0000125
thughes4ad52d02004-06-27 17:37:21 +0000126/* Let the linker know we don't need an executable stack */
127.section .note.GNU-stack,"",@progbits
128
sewardjb9bce632005-06-21 01:41:34 +0000129/*--------------------------------------------------------------------*/
130/*--- end ---*/
131/*--------------------------------------------------------------------*/