]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Replace strlen, index, strcmp in the AArch64 ld.so. (Why does it have
authorJulian Seward <jseward@acm.org>
Sun, 9 Mar 2014 09:44:32 +0000 (09:44 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 9 Mar 2014 09:44:32 +0000 (09:44 +0000)
the soname "ld-linux-aarch64.so.1" and not "ld-linux.so.3" like all
the rest?)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13858

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

index 1453b0b697fb3de4385bbe5f4f3f870e90fe9b42..69d0f3779bb753ab7293fa42ef90fe483174d258 100644 (file)
@@ -1323,21 +1323,26 @@ void VG_(redir_initialise) ( void )
    /* 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_hardwired_spec(
-   //      "ld-linux.so.3", "strlen",
-   //      (Addr)&VG_(arm_linux_REDIR_FOR_strlen),
-   //      complain_about_stripped_glibc_ldso
-   //   );
-   //   //add_hardwired_spec(
-   //   //   "ld-linux.so.3", "index",
-   //   //   (Addr)&VG_(arm_linux_REDIR_FOR_index),
-   //   //   NULL 
-   //   //);
-   //   add_hardwired_spec(
-   //      "ld-linux.so.3", "memcpy",
-   //      (Addr)&VG_(arm_linux_REDIR_FOR_memcpy),
-   //      complain_about_stripped_glibc_ldso
-   //   );
+      add_hardwired_spec(
+         "ld-linux-aarch64.so.1", "strlen",
+         (Addr)&VG_(arm64_linux_REDIR_FOR_strlen),
+         complain_about_stripped_glibc_ldso
+      );
+      add_hardwired_spec(
+         "ld-linux-aarch64.so.1", "index",
+         (Addr)&VG_(arm64_linux_REDIR_FOR_index),
+         NULL 
+      );
+      add_hardwired_spec(
+         "ld-linux-aarch64.so.1", "strcmp",
+         (Addr)&VG_(arm64_linux_REDIR_FOR_strcmp),
+         NULL 
+      );
+      //add_hardwired_spec(
+      //   "ld-linux.so.3", "memcpy",
+      //   (Addr)&VG_(arm_linux_REDIR_FOR_memcpy),
+      //   complain_about_stripped_glibc_ldso
+      //);
    }
 
 #  elif defined(VGP_x86_darwin)
index 475133f91ab10753d3c10a6269154d677950b542..a1c4dec4114693f63a1f8b265e858c157573a615 100644 (file)
@@ -706,6 +706,67 @@ VG_(arm64_linux_SUBST_FOR_rt_sigreturn):
 .size VG_(arm64_linux_SUBST_FOR_rt_sigreturn), \
         .-VG_(arm64_linux_SUBST_FOR_rt_sigreturn)
 
+.global VG_(arm64_linux_REDIR_FOR_strlen)
+.type   VG_(arm64_linux_REDIR_FOR_strlen),#function
+VG_(arm64_linux_REDIR_FOR_strlen):
+       mov     x2, x0
+       ldrb    w0, [x0]
+       cbz     w0, .L5
+       mov     x0, 0
+.L4:
+       add     x0, x0, 1
+       ldrb    w1, [x2,x0]
+       cbnz    w1, .L4
+       ret
+.L5:
+       mov     x0, 0
+       ret
+.size VG_(arm64_linux_REDIR_FOR_strlen), .-VG_(arm64_linux_REDIR_FOR_strlen)
+
+.global VG_(arm64_linux_REDIR_FOR_index)
+.type   VG_(arm64_linux_REDIR_FOR_index),#function
+VG_(arm64_linux_REDIR_FOR_index):
+        ldrb    w2, [x0]
+        uxtb    w1, w1
+        cmp     w2, w1
+        beq     .L11
+.L13:
+        cbz     w2, .L16
+        ldrb    w2, [x0,1]!
+        cmp     w2, w1
+        bne     .L13
+.L11:
+        ret
+.L16:
+        mov     x0, 0
+        ret
+.size VG_(arm64_linux_REDIR_FOR_index), .-VG_(arm64_linux_REDIR_FOR_index)
+
+.global VG_(arm64_linux_REDIR_FOR_strcmp)
+.type   VG_(arm64_linux_REDIR_FOR_strcmp),#function
+VG_(arm64_linux_REDIR_FOR_strcmp):
+        ldrb    w2, [x0]
+        ldrb    w3, [x1]
+        cmp     w2, w3
+        bcc     .L22
+.L21:
+        bhi     .L25
+        cbz     w2, .L26
+        ldrb    w2, [x0,1]!
+        ldrb    w3, [x1,1]!
+        cmp     w2, w3
+        bcs     .L21
+.L22:
+        mov     x0, -1
+        ret
+.L25:
+        mov     x0, 1
+        ret
+.L26:
+        mov     x0, 0
+        ret
+.size VG_(arm64_linux_REDIR_FOR_strcmp), .-VG_(arm64_linux_REDIR_FOR_strcmp)
+
 .global VG_(trampoline_stuff_end)
 VG_(trampoline_stuff_end):
 
index 39baac66006e2ebaddfde162ac5bfcb0d58a7220..755f8b90b26d67bb36f43e5553b158233669a194 100644 (file)
@@ -105,6 +105,9 @@ extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int );
 
 #if defined(VGP_arm64_linux)
 extern Addr  VG_(arm64_linux_SUBST_FOR_rt_sigreturn);
+extern ULong VG_(arm64_linux_REDIR_FOR_strlen)( void* );
+extern void* VG_(arm64_linux_REDIR_FOR_index) ( void*, Long );
+extern Long  VG_(arm64_linux_REDIR_FOR_strcmp)( void*, void* );
 #endif
 
 #if defined(VGP_x86_darwin)