diff --git a/libgcc/memcpy.c b/libgcc/memcpy.c index 58b1e405627aa..4a31424dd228a 100644 --- a/libgcc/memcpy.c +++ b/libgcc/memcpy.c @@ -4,9 +4,18 @@ void * memcpy (void *dest, const void *src, size_t len) { - char *d = dest; - const char *s = src; - while (len--) - *d++ = *s++; + char *d; + const char *s; + if((size_t)destination<(size_t)source){ + s=src+len; + d=dest+len; + while(len--) + *--d = *--s; + }else if((size_t)destination>(size_t)source){ + s=src; + d=dest; + while (len--) + *d++ = *s++; + } return dest; }