|
From: <sv...@va...> - 2014-03-09 09:44:45
|
Author: sewardj
Date: Sun Mar 9 09:44:32 2014
New Revision: 13858
Log:
Replace strlen, index, strcmp in the AArch64 ld.so. (Why does it have
the soname "ld-linux-aarch64.so.1" and not "ld-linux.so.3" like all
the rest?)
Modified:
trunk/coregrind/m_redir.c
trunk/coregrind/m_trampoline.S
trunk/coregrind/pub_core_trampoline.h
Modified: trunk/coregrind/m_redir.c
==============================================================================
--- trunk/coregrind/m_redir.c (original)
+++ trunk/coregrind/m_redir.c Sun Mar 9 09:44:32 2014
@@ -1323,21 +1323,26 @@
/* 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)
Modified: trunk/coregrind/m_trampoline.S
==============================================================================
--- trunk/coregrind/m_trampoline.S (original)
+++ trunk/coregrind/m_trampoline.S Sun Mar 9 09:44:32 2014
@@ -706,6 +706,67 @@
.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):
Modified: trunk/coregrind/pub_core_trampoline.h
==============================================================================
--- trunk/coregrind/pub_core_trampoline.h (original)
+++ trunk/coregrind/pub_core_trampoline.h Sun Mar 9 09:44:32 2014
@@ -105,6 +105,9 @@
#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)
|