With RPATH processing ld.so compiled for x86-64-v3 uses an optimized
avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads
of size 32 warnings.
Fix this my adding a hardwire spec with a simpler memcmp for
ld-linux-x86-64.so.2.
https://bugs.kde.org/show_bug.cgi?id=501348
Authored-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit
9ffdeb4927b8505cc5a9ea54f608f4972166bb0e)
498317 FdBadUse is not a valid CoreError type in a suppression
even though it's generated by --gen-suppressions=yes
498143 False positive on EVIOCGRAB ioctl
+501348 glibc built with -march=x86-64-v3 does not work due to ld.so memcmp
To see details of a given bug, visit
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
NULL
# else
complain_about_stripped_glibc_ldso
+# endif
+ );
+ add_hardwired_spec(
+ "ld-linux-x86-64.so.2", "memcmp",
+ (Addr)&VG_(amd64_linux_REDIR_FOR_memcmp),
+# ifndef GLIBC_MANDATORY_STRLEN_REDIRECT
+ NULL
+# else
+ complain_about_stripped_glibc_ldso
# endif
);
}
ret
.size VG_(amd64_linux_REDIR_FOR_strcmp), .-VG_(amd64_linux_REDIR_FOR_strcmp)
+.global VG_(amd64_linux_REDIR_FOR_memcmp)
+.type VG_(amd64_linux_REDIR_FOR_memcmp), @function
+VG_(amd64_linux_REDIR_FOR_memcmp):
+ xorl %ecx, %ecx
+ jmp 2f
+1:
+ movzbl (%rdi, %rcx), %eax
+ movzbl (%rsi, %rcx), %r8d
+ addq $1, %rcx
+ subl %r8d, %eax
+ jne 3f
+2:
+ cmpq %rcx, %rdx
+ jne 1b
+ xorl %eax, %eax
+3:
+ ret
+.size VG_(amd64_linux_REDIR_FOR_memcmp), .-VG_(amd64_linux_REDIR_FOR_memcmp)
+
.global VG_(amd64_linux_REDIR_FOR_index)
.type VG_(amd64_linux_REDIR_FOR_index), @function
VG_(amd64_linux_REDIR_FOR_index):
extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
extern Int VG_(amd64_linux_REDIR_FOR_strcmp)( void*, void* );
+extern Int VG_(amd64_linux_REDIR_FOR_memcmp)( void*, void*, SizeT );
extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
#endif