about summary refs log tree commit diff
path: root/src/string/arm/__aeabi_memcpy.s
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2017-02-21 00:07:34 +0000
committerRich Felker <dalias@aerifal.cx>2017-06-22 18:34:06 -0400
commite6def544358afd5648a428d2e02c147a1f901048 (patch)
tree9210513645e1a5dc230e1f128237dbe978e94ee7 /src/string/arm/__aeabi_memcpy.s
parent91d34c4533e6bf6eacad7a9f001f28f9e5ebc656 (diff)
downloadmusl-e6def544358afd5648a428d2e02c147a1f901048.tar.gz
musl-e6def544358afd5648a428d2e02c147a1f901048.tar.xz
musl-e6def544358afd5648a428d2e02c147a1f901048.zip
fix arm run-time abi string functions
in arm rtabi these __aeabi_* functions have special abi (they are
only allowed to clobber r0,r1,r2,r3,ip,lr,cpsr), so they cannot
be simple wrappers around normal string functions (which may
clobber other registers), the safest solution is to write them in
asm, a minimalistic implementation works because these are not
supposed to be emitted by compilers or used in general.
Diffstat (limited to 'src/string/arm/__aeabi_memcpy.s')
-rw-r--r--src/string/arm/__aeabi_memcpy.s45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/string/arm/__aeabi_memcpy.s b/src/string/arm/__aeabi_memcpy.s
new file mode 100644
index 00000000..3a527e41
--- /dev/null
+++ b/src/string/arm/__aeabi_memcpy.s
@@ -0,0 +1,45 @@
+.syntax unified
+
+.global __aeabi_memcpy8
+.global __aeabi_memcpy4
+.global __aeabi_memcpy
+.global __aeabi_memmove8
+.global __aeabi_memmove4
+.global __aeabi_memmove
+
+.type __aeabi_memcpy8,%function
+.type __aeabi_memcpy4,%function
+.type __aeabi_memcpy,%function
+.type __aeabi_memmove8,%function
+.type __aeabi_memmove4,%function
+.type __aeabi_memmove,%function
+
+__aeabi_memmove8:
+__aeabi_memmove4:
+__aeabi_memmove:
+	cmp   r0, r1
+	bls   3f
+	cmp   r2, #0
+	beq   2f
+	adds  r0, r0, r2
+	adds  r2, r1, r2
+1:	subs  r2, r2, #1
+	ldrb  r3, [r2]
+	subs  r0, r0, #1
+	strb  r3, [r0]
+	cmp   r1, r2
+	bne   1b
+2:	bx    lr
+__aeabi_memcpy8:
+__aeabi_memcpy4:
+__aeabi_memcpy:
+3:	cmp   r2, #0
+	beq   2f
+	adds  r2, r1, r2
+1:	ldrb  r3, [r1]
+	adds  r1, r1, #1
+	strb  r3, [r0]
+	adds  r0, r0, #1
+	cmp   r1, r2
+	bne   1b
+2:	bx    lr