Home | History | Annotate | Download | only in coregrind
      1 
      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 
     10    Copyright (C) 2000-2012 Julian Seward
     11       jseward (at) 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 //--------------------------------------------------------------------
     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.
     40 //
     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 //--------------------------------------------------------------------
     50 
     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
     54    invalid addresses. */
     55 
     56 extern Addr VG_(trampoline_stuff_start);
     57 extern Addr VG_(trampoline_stuff_end);
     58 
     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* );
     64 #endif
     65 
     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 Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
     71 extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
     72 #endif
     73 
     74 #if defined(VGP_ppc32_linux)
     75 extern Addr  VG_(ppc32_linux_SUBST_FOR_sigreturn);
     76 extern Addr  VG_(ppc32_linux_SUBST_FOR_rt_sigreturn);
     77 extern UInt  VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
     78 extern UInt  VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
     79 extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
     80 #endif
     81 
     82 #if defined(VGP_ppc64_linux)
     83 extern Addr  VG_(ppc64_linux_SUBST_FOR_rt_sigreturn);
     84 extern UInt  VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
     85 extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
     86 /* A label (sans dot) marking the ultra-magical return stub via which
     87    all redirected and wrapped functions are made to "return" on
     88    ppc64-linux.  The one insn at this label is never really
     89    translated.  Instead, m_translate generates IR to restore the
     90    thread's LR and R2 registers from a small stack in the ppc64 guest
     91    state structure, and then branch to LR.  Convoluted?  Confusing?
     92    You betcha.  Could I think of anything simpler?  No. */
     93 extern Addr VG_(ppctoc_magic_redirect_return_stub);
     94 #endif
     95 
     96 #if defined(VGP_arm_linux)
     97 extern Addr  VG_(arm_linux_SUBST_FOR_sigreturn);
     98 extern Addr  VG_(arm_linux_SUBST_FOR_rt_sigreturn);
     99 extern UInt  VG_(arm_linux_REDIR_FOR_strlen)( void* );
    100 //extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int );
    101 extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
    102 #endif
    103 
    104 #if defined(VGP_x86_darwin)
    105 extern Addr  VG_(x86_darwin_SUBST_FOR_sigreturn);
    106 extern SizeT VG_(x86_darwin_REDIR_FOR_strlen)( void* );
    107 extern SizeT VG_(x86_darwin_REDIR_FOR_strcmp)( void*, void* );
    108 extern void* VG_(x86_darwin_REDIR_FOR_strcat)( void*, void * );
    109 extern char* VG_(x86_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
    110 extern SizeT VG_(x86_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
    111                                                 SizeT size );
    112 #endif
    113 
    114 #if defined(VGP_amd64_darwin)
    115 extern Addr  VG_(amd64_darwin_SUBST_FOR_sigreturn);
    116 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlen)( void* );
    117 extern SizeT VG_(amd64_darwin_REDIR_FOR_strcmp)( void*, void* );
    118 extern void* VG_(amd64_darwin_REDIR_FOR_strcat)( void*, void * );
    119 extern char* VG_(amd64_darwin_REDIR_FOR_strcpy)( char *s1, char *s2 );
    120 extern SizeT VG_(amd64_darwin_REDIR_FOR_strlcat)( char *s1, const char *s2,
    121                                                   SizeT size );
    122 extern UInt VG_(amd64_darwin_REDIR_FOR_arc4random)( void );
    123 #endif
    124 
    125 #if defined(VGP_s390x_linux)
    126 extern Addr VG_(s390x_linux_SUBST_FOR_sigreturn);
    127 extern Addr VG_(s390x_linux_SUBST_FOR_rt_sigreturn);
    128 #endif
    129 
    130 #if defined(VGP_mips32_linux)
    131 extern Addr  VG_(mips32_linux_SUBST_FOR_sigreturn);
    132 extern Addr  VG_(mips32_linux_SUBST_FOR_rt_sigreturn);
    133 extern UInt  VG_(mips32_linux_REDIR_FOR_strlen)( void* );
    134 #endif
    135 
    136 #endif   // __PUB_CORE_TRAMPOLINE_H
    137 
    138 /*--------------------------------------------------------------------*/
    139 /*--- end                                                          ---*/
    140 /*--------------------------------------------------------------------*/
    141