Bug in m68k memcpy/memcmp

Jeff Johnston jjohnstn@redhat.com
Sat Apr 28 06:50:00 GMT 2007


Being that it is Friday, I have made a patch to temporarily remove 
memcpy.S and memset.S from being built until this can be resolved.

-- Jeff J.

Eric Norum wrote:
> The proposed patch to the M68k versions of memcpy/memset has a nasty bug:
> 
> 
> +.Lcopy:
> +#if !defined (__mcoldfire__)
> +    dbra    %d0,1b
> +#else
> +    subq.l    #1,%d0
> +    bpl    1b
> +#endif
> 
> The non-ColdFire version uses dbra -- which uses only the lower 16-bits 
> of the counter register.
> The above code will fail for transfers greater than 16*65535 bytes.
> 
> There needs to be another decrement of the most-significant 16-bits of 
> the count register and another conditional branch and conditional branch 
> added to all the 'dbra' loop tests.
> 
> Off the top of my head, I think that there needs to be something like:
> +.Lcopy:
> +#if !defined (__mcoldfire__)
> +    dbra    %d0,1b
> +      subl         #0x10000,d0
> +     bpl           1b
> +#else
> +    subq.l    #1,%d0
> +    bpl    1b
> +#endif
> 
> 
> --Eric Norum <norume@aps.anl.gov>
> Advanced Photon Source
> Argonne National Laboratory
> (630) 252-4793
> 
> 



More information about the Newlib mailing list