Subject: port-arm/36512: memmove doesn't fall back to memcpy
To: None <port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Hiroki Doshita <doshita@iij.ad.jp>
List: netbsd-bugs
Date: 06/20/2007 01:25:00
>Number:         36512
>Category:       port-arm
>Synopsis:       memmove doesn't fall back to memcpy
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 20 01:25:00 +0000 2007
>Originator:     Hiroki Doshita
>Release:        NetBSD 3.1
>Organization:
	Internet Initiative Japan, Inc.
>Environment:
Architecture: arm
Machine: armeb
>Description:
	the judgement of buffer overlap in xscale's memmove is wrong.

>How-To-Repeat:
>Fix:
Index: src/lib/libc/arch/arm/string/memmove.S
diff -u src/lib/libc/arch/arm/string/memmove.S:1.2 src/lib/libc/arch/arm/string/memmove.S:1.3
--- src/lib/libc/arch/arm/string/memmove.S:1.2	Mon Nov 17 15:25:34 2003
+++ src/lib/libc/arch/arm/string/memmove.S	Mon Jun 18 18:23:39 2007
@@ -53,10 +53,10 @@
 	/* Do the buffers overlap? */
 	cmp	r0, r1
 	moveq	pc, lr		/* Bail now if src/dst are the same */
-	subcc	r3, r0, r1	/* if (dst > src) r3 = dst - src */
-	subcs	r3, r1, r0	/* if (src > dsr) r3 = src - dst */
-	cmp	r3, r2		/* if (r3 < len) we have an overlap */
-	bcc	PIC_SYM(_C_LABEL(memcpy), PLT)
+	subhs	r3, r0, r1	/* if (dst > src) r3 = dst - src */
+	sublo	r3, r1, r0	/* if (src > dsr) r3 = src - dst */
+	cmp	r3, r2		/* if (r3 >= len) we have no overlap */
+	bhs	PIC_SYM(_C_LABEL(memcpy), PLT)
 
 	/* Determine copy direction */
 	cmp	r1, r0