]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Darwin redirs: add several str* amd mem* redirs to vg_replace_strmem.c
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 9 Nov 2025 20:57:01 +0000 (21:57 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 9 Nov 2025 20:57:01 +0000 (21:57 +0100)
Mostly these are _chk variants. I've also undone a change that
forced the compiler to not use these variants.

memcheck/tests/Makefile.am
memcheck/tests/filter_libc_variants
memcheck/tests/memccpy2.c
memcheck/tests/overlap.c
memcheck/tests/overlap.vgtest
shared/vg_replace_strmem.c

index 6343b1b7c863e05d945f1907f97390a61f4c0a28..5cdc2082c9b55fb392f37cc826c9e874a37716c0 100644 (file)
@@ -814,7 +814,13 @@ origin4_many_CFLAGS        = $(AM_CFLAGS) -O @FLAG_W_NO_USE_AFTER_FREE@ @FLAG_W_NO_UNIN
 
 # Apply -O so as to run in reasonable time.
 origin5_bz2_CFLAGS     = $(AM_CFLAGS) -O -Wno-inline
+if VGCONF_OS_IS_DARWIN
+origin5_bz2_CFLAGS             += -fno-inline
+endif
 origin6_fp_CFLAGS      = $(AM_CFLAGS) -O
+if VGCONF_OS_IS_DARWIN
+origin6_fp_CFLAGS              += -fno-inline
+endif
 
 # Don't allow GCC to inline memcpy() and strcpy(),
 # because then we can't intercept it
@@ -876,11 +882,27 @@ wrap6_CFLAGS              = $(AM_CFLAGS) -O2
 # To make it a bit more realistic, have some optimisation enabled
 # for the varinfo tests.  We still expect sane results.
 varinfo1_CFLAGS                = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@
+if VGCONF_OS_IS_DARWIN
+varinfo1_CFLAGS                += -fno-inline
+endif
 varinfo2_CFLAGS                = $(AM_CFLAGS) -O -Wno-shadow @FLAG_W_NO_MAYBE_UNINITIALIZED@
+if VGCONF_OS_IS_DARWIN
+varinfo2_CFLAGS         += -fno-inline
+endif
 varinfo3_CFLAGS                = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@
+if VGCONF_OS_IS_DARWIN
+varinfo3_CFLAGS         += -fno-inline
+endif
 varinfo4_CFLAGS                = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@
+if VGCONF_OS_IS_DARWIN
+varinfo4_CFLAGS         += -fno-inline
+endif
 varinfo5_CFLAGS                = $(AM_CFLAGS) -O
 varinfo6_CFLAGS                = $(AM_CFLAGS) -O @FLAG_W_NO_MAYBE_UNINITIALIZED@
+if VGCONF_OS_IS_DARWIN
+varinfo6_CFLAGS         += -fno-inline
+endif
+
 
 # Build shared object for varinfo5
 varinfo5_SOURCES        = varinfo5.c
index bfffa84689d4457c0b2b9e364499583d877c5514..3ecf1fb808fa3c05b09958be6796aad5285a3687 100755 (executable)
@@ -2,4 +2,4 @@
 
 ./filter_stderr "$@" |
 
-sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /;s/ _platform_memccpy / memccpy /'
+sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /;s/ _platform_memccpy / memccpy /;s/ __memccpy_chk / memccpy /;s/ __strncat_chk / strncat /;s/ __strncpy_chk / strncpy /;s/ __strcpy_chk / strcpy /'
index be7808d5fda5c71b444de8f37f5a59927bcd0f6e..947324581715a7cb52fff98f72ebe05d4182c183 100644 (file)
@@ -8,9 +8,9 @@ int main(void)
 {
    char* astring = strdup("this is a string # with something to seek");
    size_t len = strlen(astring);
-   (memccpy)(astring+10, astring, '#', len-10);
+   memccpy(astring+10, astring, '#', len-10);
    sprintf(astring, "this is a string # with something to seek");
-   (memccpy)(astring, astring+10, '#', len);
+   memccpy(astring, astring+10, '#', len);
    
    sprintf(astring, "this is a string # with something to seek");
    /*
@@ -23,10 +23,10 @@ int main(void)
    assert(res && *res == 'g');
    sprintf(astring, "this is a string # with something to seek");
    /* length is 0, nothing copied, returns NULL */
-   res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0);
+   res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0);
    assert(NULL == res);
    /* 'z' not found so 20 bytes copied, returns NULL */
-   res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20);
+   res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20);
    assert(NULL == res);
    free(astring);
 }
index 649b1e34d354dc83f2e0475e26e5ba9f0fa30e54..d868886f381f3f17a41abbc4776b28be4ed60a51 100644 (file)
@@ -42,16 +42,16 @@ int main(void)
    memcpy(x, x+20, 21);    // overlap
 
    strncpy(x+20, x, 20);    // ok
-   (strncpy)(x+20, x, 21);    // overlap
+   strncpy(x+20, x, 21);    // overlap
    strncpy(x, x+20, 20);    // ok
-   (strncpy)(x, x+20, 21);    // overlap
+   strncpy(x, x+20, 21);    // overlap
    
    x[39] = '\0';
    strcpy(x, x+20);    // ok
 
    x[39] = 39;
    x[40] = '\0';
-   (strcpy)(x, x+20);    // overlap
+   strcpy(x, x+20);    // overlap
 
    x[19] = '\0';
    strcpy(x+20, x);    // ok
@@ -109,8 +109,8 @@ int main(void)
       always run forever, I think... */
 
    for ( i = 0; i < 2; i++) 
-      (strncat)(a+20, a, 21);    // run twice to check 2nd error isn't shown
-   (strncat)(a, a+20, 21);
+      strncat(a+20, a, 21);    // run twice to check 2nd error isn't shown
+   strncat(a, a+20, 21);
 
    /* This is ok, but once gave a warning when strncpy() was wrong,
       and used 'n' for the length, even when the src was shorter than 'n' */
index 7e49d95c8050af1653ac269a9fcc6ece95417912..166bf73f7ea319d6168724d445b08064768a2664 100644 (file)
@@ -2,3 +2,4 @@ prog: overlap
 vgopts: -q
 # https://bugs.kde.org/show_bug.cgi?id=402833
 prereq: ! ../../tests/os_test linux || ! ../../tests/arch_test amd64
+stderr_filter: filter_libc_variants
index 5ef4884efa07d12ca418d8f78e27e86271d92b7f..d9de90b41160ef8d3ebc6efe6fa141ced54a5c05 100644 (file)
@@ -386,7 +386,8 @@ static inline void my_exit ( int x )
  STRNCAT(VG_Z_LIBC_SONAME, strncat)
 
 #elif defined(VGO_darwin)
- //STRNCAT(VG_Z_LIBC_SONAME, strncat)
+ STRNCAT(VG_Z_LIBSYSTEM_C_SONAME, strncat)
+ STRNCAT(VG_Z_LIBSYSTEM_C_SONAME, __strncat_chk)
  //STRNCAT(VG_Z_DYLD,        strncat)
 
 #elif defined(VGO_solaris)
@@ -572,9 +573,8 @@ static inline void my_exit ( int x )
 
 #elif defined(VGO_darwin)
  STRCPY(VG_Z_LIBC_SONAME, strcpy)
-# if DARWIN_VERS == DARWIN_10_9
-  STRCPY(VG_Z_LIBSYSTEM_C_SONAME, strcpy)
-# endif
+ STRCPY(VG_Z_LIBSYSTEM_C_SONAME, strcpy)
+ STRCPY(VG_Z_LIBSYSTEM_C_SONAME, __strcpy_chk)
 
 #elif defined(VGO_solaris)
  STRCPY(VG_Z_LIBC_SONAME, strcpy)
@@ -620,9 +620,8 @@ static inline void my_exit ( int x )
 
 #elif defined(VGO_darwin)
  STRNCPY(VG_Z_LIBC_SONAME, strncpy)
-# if DARWIN_VERS >= DARWIN_10_9
-  STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, strncpy)
-# endif
+ STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, strncpy)
+ STRNCPY(VG_Z_LIBSYSTEM_C_SONAME, __strncpy_chk)
 
 #elif defined(VGO_solaris)
  STRNCPY(VG_Z_LIBC_SONAME, strncpy)
@@ -1175,6 +1174,7 @@ static inline void my_exit ( int x )
 # endif
  MEMCPY(VG_Z_LIBC_SONAME,  memcpyZDVARIANTZDsse3x) /* memcpy$VARIANT$sse3x */
  MEMCPY(VG_Z_LIBC_SONAME,  memcpyZDVARIANTZDsse42) /* memcpy$VARIANT$sse42 */
+ MEMCPY(VG_Z_LIBSYSTEM_C_SONAME, __memcpy_chk)
 
 #elif defined(VGO_solaris)
  MEMCPY(VG_Z_LIBC_SONAME,  memcpy)
@@ -2383,6 +2383,7 @@ static inline void my_exit ( int x )
 #if defined(VGO_linux) || defined(VGO_freebsd) || defined(VGO_solaris)
  MEMCCPY(VG_Z_LIBC_SONAME, memccpy)
 #elif defined(VGO_darwin)
+ MEMCCPY(VG_Z_LIBSYSTEM_C_SONAME, __memccpy_chk)
  MEMCCPY(VG_Z_LIBSYSTEM_PLATFORM_SONAME, _platform_memccpy)
 #endif