From 13f7d71fee36dda6a9bc4d81f4c5215d2d2a605a Mon Sep 17 00:00:00 2001 From: Joern Rennecke Date: Thu, 13 Jun 2002 18:25:19 +0000 Subject: [PATCH] * libc/machine/sh/strcpy.S (strcpy, __SHMEDIA__ code): Fix clobbering bytes before destination if src and dst have same non-zero misalignment. --- newlib/ChangeLog | 6 +++++- newlib/libc/machine/sh/strcpy.S | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index efa387458..c51adc4de 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,4 +1,8 @@ -Thu Jun 13 15:52:03 2002 J"orn Rennecke +Thu Jun 13 19:23:40 2002 J"orn Rennecke + + * libc/machine/sh/strcpy.S (strcpy, __SHMEDIA__ code): + Fix clobbering bytes before destination if src and dst have same + non-zero misalignment. * libc/machine/sh/memset.S (memset, __SHMEDIA__ code): Fixed bug in writing end of set region. diff --git a/newlib/libc/machine/sh/strcpy.S b/newlib/libc/machine/sh/strcpy.S index fa41cd2a5..da951cd03 100644 --- a/newlib/libc/machine/sh/strcpy.S +++ b/newlib/libc/machine/sh/strcpy.S @@ -27,9 +27,11 @@ ENTRY(strcpy) pta/l loop, tr0 ori r2,-8,r22 mcmpeq.b r5, r63, r6 - bge/u r22, r23, tr2 // no_lddst + bgt/u r22, r23, tr2 // no_lddst - // r22 < r23 ; Need to do a load from the destination. + // r22 < r23 : Need to do a load from the destination. + // r22 == r23 : Doesn't actually need to load from destination, + // but still can be handled here. ldlo.q r2, 0, r9 movi -1, r8 SHLO r8, r7, r8 @@ -41,6 +43,8 @@ ENTRY(strcpy) addi r0, 8, r0 blink tr1, r63 // shortstring no_lddst: + // r22 > r23: note that for r22 == r23 the sthi.q would clobber + // bytes before the destination region. stlo.q r2, 0, r4 SHHI r4, r7, r4 sthi.q r0, -1, r4