[PATCH 1/2] msvcrt: Add DECLSPEC_HOTPATCH to strlen and strrchr.

Roman Pišl rpisl at seznam.cz
Wed Dec 8 16:52:58 CST 2021


I see no other way how to make Clang ASAN work.
ASAN recognizes first instruction(s) and inserts trampoline, but the loop
in the function body jumps back to the start of the function (and hangs)
or somewhere inside the trampoline (that leads to invalid instruction).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50993
Signed-off-by: Roman Pišl <rpisl at seznam.cz>
---
 dlls/msvcrt/string.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index d92b7a38d12..9fa8700da3d 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -1510,7 +1510,7 @@ int CDECL _atoldbl(_LDOUBLE *value, char *str)
 /*********************************************************************
  *              strlen (MSVCRT.@)
  */
-size_t __cdecl strlen(const char *str)
+size_t __cdecl DECLSPEC_HOTPATCH strlen(const char *str)
 {
     const char *s = str;
     while (*s) s++;
@@ -3160,7 +3160,7 @@ char* __cdecl strchr(const char *str, int c)
 /*********************************************************************
  *                  strrchr (MSVCRT.@)
  */
-char* __cdecl strrchr(const char *str, int c)
+char* __cdecl DECLSPEC_HOTPATCH strrchr(const char *str, int c)
 {
     char *ret = NULL;
     do { if (*str == (char)c) ret = (char*)str; } while (*str++);
-- 
2.30.2




More information about the wine-devel mailing list