]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Initial redirect stuff for ppc64-linux.
authorJulian Seward <jseward@acm.org>
Thu, 5 Jan 2006 14:07:04 +0000 (14:07 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 5 Jan 2006 14:07:04 +0000 (14:07 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5499

coregrind/m_main.c
coregrind/m_redir.c
coregrind/m_trampoline.S
coregrind/pub_core_trampoline.h

index 63e5e1448f00778b34b0f7e05aca2af2d0364c52..4500c222a0e8f671db46d865700310040bab7e66 100644 (file)
@@ -2398,8 +2398,12 @@ Int main(Int argc, HChar **argv, HChar **envp)
    //   p: aspacem
    //--------------------------------------------------------------
    { Bool change_ownership_v_c_OK;
-     Addr co_start   = VG_PGROUNDDN( (Addr)&VG_(trampoline_stuff_start) );
-     Addr co_endPlus = VG_PGROUNDUP( (Addr)&VG_(trampoline_stuff_end) );
+     Addr co_start   = VG_PGROUNDDN( 
+                          (Addr)VG_(fnptr_to_fnentry)( 
+                             &VG_(trampoline_stuff_start) ) );
+     Addr co_endPlus = VG_PGROUNDUP( 
+                          (Addr)VG_(fnptr_to_fnentry)( 
+                             &VG_(trampoline_stuff_end) ) );
      VG_(debugLog)(1,"redir",
                      "transfer ownership V -> C of 0x%llx .. 0x%llx\n",
                      (ULong)co_start, (ULong)co_endPlus-1 );
index 1539980034021776f78dc11ec75d0d3a92890737..53b0dddd2ee5a907bc517d4d7e860346f2e6576d 100644 (file)
@@ -43,6 +43,7 @@
 #include "pub_core_trampoline.h"
 #include "pub_core_transtab.h"
 #include "pub_core_tooliface.h"    // VG_(needs).malloc_replacement
+#include "pub_tool_machine.h"      // VG_(fnptr_to_fnentry)
 
 
 /*------------------------------------------------------------*/
@@ -406,7 +407,16 @@ void VG_(setup_code_redirect_table) ( void )
 
 #elif defined(VGP_ppc64_linux)
 
-   // we'll have to stick some godawful hacks in here, no doubt
+   /* If we're using memcheck, use these intercepts right from
+      the start, otherwise ld.so makes a lot of noise. */
+   if (0==VG_(strcmp)("Memcheck", VG_(details).name)) {
+
+      add_redirect_sym_to_addr(
+         "soname:ld64.so.1", "strlen",
+         (Addr)VG_(fnptr_to_fnentry)( &VG_(ppc64_linux_REDIR_FOR_strlen) )
+      );   
+
+   }
 
 #else
 #  error Unknown platform
index 1da47dde6d0b8405892d44f098a73674d6a2ad70..f2e0c8a32fb0e66785019f34d67cd8968b69aae6 100644 (file)
@@ -277,6 +277,9 @@ VG_(ppc32_linux_REDIR_FOR_strchr):
 .global VG_(trampoline_stuff_end)
 VG_(trampoline_stuff_end):
 
+       /* and a trailing page of unexecutable code */
+       UD2_PAGE
+
 #      undef UD2_16
 #      undef UD2_64
 #      undef UD2_256
@@ -306,7 +309,32 @@ VG_(trampoline_stuff_start):
 .type .VG_(trampoline_stuff_start),@function
 .global  .VG_(trampoline_stuff_start)
 .VG_(trampoline_stuff_start):
-       
+
+.align 2
+.globl VG_(ppc64_linux_REDIR_FOR_strlen)
+.section        ".opd","aw"
+.align 3
+VG_(ppc64_linux_REDIR_FOR_strlen):
+.quad   .L.VG_(ppc64_linux_REDIR_FOR_strlen),.TOC.@tocbase
+.previous
+.type   VG_(ppc64_linux_REDIR_FOR_strlen), @function
+.L.VG_(ppc64_linux_REDIR_FOR_strlen):
+        mr 9,3
+        lbz 0,0(3)
+        li 3,0
+        cmpwi 7,0,0
+        beqlr 7
+        li 3,0
+.L5:
+        addi 0,3,1
+        extsw 3,0
+        lbzx 0,9,3
+        cmpwi 7,0,0
+        bne 7,.L5
+        blr
+        .long 0
+        .byte 0,0,0,0,0,0,0,0
+        .size   VG_(ppc64_linux_REDIR_FOR_strlen),.-.L.VG_(ppc64_linux_REDIR_FOR_strlen)
 
 .align 2
 .global VG_(trampoline_stuff_end)
@@ -319,6 +347,9 @@ VG_(trampoline_stuff_end):
 .global  .VG_(trampoline_stuff_end)
 .VG_(trampoline_stuff_end):
 
+       /* and a trailing page of unexecutable code */
+       UD2_PAGE
+
 #      undef UD2_16
 #      undef UD2_64
 #      undef UD2_256
index 68e1f7a3d354b7b4a8353a324cde325a96a8512a..0113fa70cbd49af6c4ef7b9c08f6f6b4a79dc94f 100644 (file)
@@ -65,6 +65,10 @@ extern UInt  VG_(ppc32_linux_REDIR_FOR_strlen)( void* );
 extern UInt  VG_(ppc32_linux_REDIR_FOR_strcmp)( void*, void* );
 extern void* VG_(ppc32_linux_REDIR_FOR_strchr)( void*, Int );
 #endif
+
+#if defined(VGP_ppc64_linux)
+extern UInt  VG_(ppc64_linux_REDIR_FOR_strlen)( void* );
+#endif
  
 #endif   // __PUB_CORE_TRAMPOLINE_H