On Tue, 4 Sep 2001, Gwenole Beauchesne wrote:
> On Tue, 4 Sep 2001, Daniel Kobras wrote:
>
> [assembly dumps]
>
> > Comments?
>
> Indeed, that's in the core (unpatched) glibc-2.2.4 sources:
>
> glibc-2.2.4/sysdeps/i386/i586/memcpy.S
>
> [...]
>
> movl %eax, %ecx
> subl $32, %ecx
> js L(2)
>
> /* Read ahead to make sure we write in the cache since the stupid
> i586 designers haven't implemented read-on-write-miss. */
> movl (%edi), %eax
> L(3): movl 28(%edi), %edx
>
> /* Now correct the loop counter. Please note that in the
> following
> code the flags are not changed anymore. */
> subl $32, %ecx
>
> [...]
>
> Wow, the most outstanding thing is that this piece of code haven't changed
> since: "Revision 1.1, Tue Nov 11 23:38:36 1997 UTC (3 years, 9 months ago)
> by drepper"
Of course usually nobody will notice that, as gcc will use
__builtin_memcpy, if compiled with -O or up. The question is, is it
legal for memcpy to read from the destination? In fact, if copying is
unaligned, architectures like Alpha may need to do a read-modify-write
cycle on the destination? (where of course protection flag problems
cannot arise, as these are "page aligned").
Richard.
>
> For reference:
>
><http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/i586/memcpy.S?cvsroot=glibc>
>
> Thanks,
> Gwenole
>
--
Richard Guenther <[EMAIL PROTECTED]>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/