njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 1 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Trampoline code page stuff. m_trampoline.S ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 5 | |
| 6 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 9 | |
njn | 5361242 | 2005-03-12 16:22:54 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2005 Julian Seward |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 11 | jseward@acm.org |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 28 | The GNU General Public License is contained in the file COPYING. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 31 | #include "pub_tool_basics_asm.h" |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 32 | #include "vki_unistd.h" |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 33 | |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 34 | /* ------------------ SIMULATED CPU HELPERS ------------------ */ |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 35 | /* |
| 36 | Replacements for some functions to do with vsyscalls and signals. |
| 37 | This code runs on the simulated CPU. |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 38 | */ |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 39 | |
sewardj | 05b5fc1 | 2005-06-21 09:56:56 +0000 | [diff] [blame] | 40 | /*---------------- x86-linux ----------------*/ |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 41 | #if defined(VGP_x86_linux) |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 42 | |
| 43 | .global VG_(trampoline_stuff_start) |
| 44 | VG_(trampoline_stuff_start): |
| 45 | |
| 46 | .global VG_(x86_linux_SUBST_FOR_sigreturn) |
| 47 | VG_(x86_linux_SUBST_FOR_sigreturn): |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 48 | /* 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 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 55 | .global VG_(x86_linux_SUBST_FOR_rt_sigreturn) |
| 56 | VG_(x86_linux_SUBST_FOR_rt_sigreturn): |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 57 | /* Likewise for rt signal frames */ |
| 58 | movl $__NR_rt_sigreturn, %eax |
| 59 | int $0x80 |
| 60 | ud2 |
fitzhardinge | 98abfc7 | 2003-12-16 02:05:15 +0000 | [diff] [blame] | 61 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 62 | .global VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80) |
| 63 | VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80): |
| 64 | /* We can point our sysinfo stuff here */ |
fitzhardinge | 9236079 | 2003-12-24 10:11:11 +0000 | [diff] [blame] | 65 | int $0x80 |
| 66 | ret |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 67 | |
| 68 | .global VG_(trampoline_stuff_end) |
| 69 | VG_(trampoline_stuff_end): |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 70 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 71 | |
sewardj | 05b5fc1 | 2005-06-21 09:56:56 +0000 | [diff] [blame] | 72 | /*---------------- amd64-linux ----------------*/ |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 73 | #else |
| 74 | #if defined(VGP_amd64_linux) |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 75 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 76 | .global VG_(trampoline_stuff_start) |
| 77 | VG_(trampoline_stuff_start): |
| 78 | |
| 79 | .global VG_(amd64_linux_SUBST_FOR_rt_sigreturn) |
| 80 | VG_(amd64_linux_SUBST_FOR_rt_sigreturn): |
| 81 | /* This is a very specific sequence which GDB uses to |
| 82 | recognize signal handler frames. */ |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 83 | movq $__NR_rt_sigreturn, %rax |
| 84 | syscall |
| 85 | ud2 |
| 86 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 87 | .global VG_(amd64_linux_REDIR_FOR_vgettimeofday) |
| 88 | VG_(amd64_linux_REDIR_FOR_vgettimeofday): |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 89 | movq $__NR_gettimeofday, %rax |
| 90 | syscall |
| 91 | ret |
| 92 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 93 | .global VG_(amd64_linux_REDIR_FOR_vtime) |
| 94 | VG_(amd64_linux_REDIR_FOR_vtime): |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 95 | movq $__NR_time, %rax |
| 96 | syscall |
| 97 | ret |
| 98 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 99 | .global VG_(trampoline_stuff_end) |
| 100 | VG_(trampoline_stuff_end): |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 101 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 102 | |
sewardj | 05b5fc1 | 2005-06-21 09:56:56 +0000 | [diff] [blame] | 103 | /*---------------- ppc32-linux ----------------*/ |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 104 | #else |
| 105 | #if defined(VGP_ppc32_linux) |
| 106 | |
sewardj | 05b5fc1 | 2005-06-21 09:56:56 +0000 | [diff] [blame] | 107 | .global VG_(trampoline_stuff_start) |
| 108 | VG_(trampoline_stuff_start): |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 109 | |
sewardj | 05b5fc1 | 2005-06-21 09:56:56 +0000 | [diff] [blame] | 110 | .global VG_(trampoline_stuff_end) |
| 111 | VG_(trampoline_stuff_end): |
| 112 | |
| 113 | |
| 114 | |
| 115 | /*---------------- unknown ----------------*/ |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 116 | #else |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 117 | # error Unknown platform |
| 118 | |
njn | a7598f6 | 2005-06-18 03:27:58 +0000 | [diff] [blame] | 119 | #endif |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 120 | #endif |
| 121 | #endif |
| 122 | |
fitzhardinge | 9236079 | 2003-12-24 10:11:11 +0000 | [diff] [blame] | 123 | tramp_code_end: |
sewardj | bc5b99f | 2002-04-13 00:08:51 +0000 | [diff] [blame] | 124 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 125 | |
thughes | 4ad52d0 | 2004-06-27 17:37:21 +0000 | [diff] [blame] | 126 | /* Let the linker know we don't need an executable stack */ |
| 127 | .section .note.GNU-stack,"",@progbits |
| 128 | |
sewardj | b9bce63 | 2005-06-21 01:41:34 +0000 | [diff] [blame] | 129 | /*--------------------------------------------------------------------*/ |
| 130 | /*--- end ---*/ |
| 131 | /*--------------------------------------------------------------------*/ |