]>
Commit | Line | Data |
---|---|---|
30a4e827 MT |
1 | This is a workaround for broken code which issues memcpy requests with |
2 | overlapping arguments. With this patch installed, if the file | |
3 | /etc/sysconfig/32bit_ssse3_memcpy_via_32bit_ssse3_memmove exists then a | |
4 | 32bit memcpy call which normally would be handled by the SSSE3 memcpy | |
5 | implementation would instead be handled by the 32bit SSSE3 memmove | |
6 | implementation which is more tolerant of overlaps. | |
7 | ||
8 | diff -Nrup a/sysdeps/i386/i686/multiarch/memcpy.S b/sysdeps/i386/i686/multiarch/memcpy.S | |
9 | --- a/sysdeps/i386/i686/multiarch/memcpy.S 2010-05-04 05:27:23.000000000 -0600 | |
10 | +++ b/sysdeps/i386/i686/multiarch/memcpy.S 2012-11-20 14:19:52.890780415 -0700 | |
11 | @@ -21,6 +21,10 @@ | |
12 | #include <sysdep.h> | |
13 | #include <init-arch.h> | |
14 | ||
15 | + .section .rodata | |
16 | +L(magicfile): | |
17 | + .ascii "/etc/sysconfig/32bit_ssse3_memcpy_via_32bit_ssse3_memmove" | |
18 | + | |
19 | /* Define multiple versions only for the definition in lib and for | |
20 | DSO. In static binaries we need memcpy before the initialization | |
21 | happened. */ | |
22 | @@ -48,6 +52,26 @@ ENTRY(memcpy) | |
23 | 1: leal __memcpy_ia32@GOTOFF(%ebx), %eax | |
24 | testl $bit_SSSE3, CPUID_OFFSET+index_SSSE3+__cpu_features@GOTOFF(%ebx) | |
25 | jz 2f | |
26 | + | |
27 | + /* This is an inlined access (magicfile, 0) syscall. | |
28 | + | |
29 | + Note that it clobbers %ebx, so we have to save/restore | |
30 | + it around the syscall. */ | |
31 | + mov %ebx, %edx | |
32 | + leal L(magicfile)@GOTOFF(%ebx), %ebx | |
33 | + xor %ecx, %ecx | |
34 | + movl $33, %eax | |
35 | + int $0x80 | |
36 | + mov %edx, %ebx | |
37 | + | |
38 | + /* If the file did not exist, then %eax will be -1..-4095 and we | |
39 | + do nothing special. */ | |
40 | + cmpl $-4095, %eax | |
41 | + jae 4f | |
42 | + | |
43 | + leal __memmove_ssse3@GOTOFF(%ebx), %eax | |
44 | + jmp 2f | |
45 | +4: | |
46 | leal __memcpy_ssse3@GOTOFF(%ebx), %eax | |
47 | testl $bit_Fast_Rep_String, FEATURE_OFFSET+index_Fast_Rep_String+__cpu_features@GOTOFF(%ebx) | |
48 | jz 2f |