From: Adhemerval Zanella Date: Wed, 2 Apr 2025 15:51:51 +0000 (-0300) Subject: Extend malloc function hiding to tst-memaling-2 and tst-reallocarray (BZ #32366) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d291ddf01da4e3f0839eb4861fe6c014c854b2fe;p=thirdparty%2Fglibc.git Extend malloc function hiding to tst-memaling-2 and tst-reallocarray (BZ #32366) Add "tst-malloc-aux.h" on tst-memalign-2.c and extend the mechanism to handle reallocarray as well (clang-20 also optimize-out reallocarray). --- diff --git a/malloc/tst-malloc-aux.h b/malloc/tst-malloc-aux.h index cd752afa8b..8bed28583a 100644 --- a/malloc/tst-malloc-aux.h +++ b/malloc/tst-malloc-aux.h @@ -34,6 +34,7 @@ static __typeof (posix_memalign) * volatile posix_memalign_indirect static __typeof (pvalloc) * volatile pvalloc_indirect = pvalloc; static __typeof (realloc) * volatile realloc_indirect = realloc; static __typeof (valloc) * volatile valloc_indirect = valloc; +static __typeof (reallocarray) * volatile reallocarray_indirect = reallocarray; #undef aligned_alloc #undef calloc @@ -43,6 +44,7 @@ static __typeof (valloc) * volatile valloc_indirect = valloc; #undef pvalloc #undef realloc #undef valloc +#undef reallocarray #define aligned_alloc aligned_alloc_indirect #define calloc calloc_indirect @@ -52,5 +54,6 @@ static __typeof (valloc) * volatile valloc_indirect = valloc; #define pvalloc pvalloc_indirect #define realloc realloc_indirect #define valloc valloc_indirect +#define reallocarray reallocarray_indirect #endif /* TST_MALLOC_AUX_H */ diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c index 4494e641c6..61f9fad3e8 100644 --- a/malloc/tst-memalign-2.c +++ b/malloc/tst-memalign-2.c @@ -25,6 +25,8 @@ #include #include +#include "tst-malloc-aux.h" + typedef struct TestCase { size_t size; size_t alignment; diff --git a/malloc/tst-memalign-3.c b/malloc/tst-memalign-3.c index 4b462f08c9..7c6ca49cf4 100644 --- a/malloc/tst-memalign-3.c +++ b/malloc/tst-memalign-3.c @@ -27,6 +27,7 @@ #include #include +#include "tst-malloc-aux.h" typedef struct TestCase { size_t size; diff --git a/malloc/tst-reallocarray.c b/malloc/tst-reallocarray.c index b4df4aa4e6..9df61c317d 100644 --- a/malloc/tst-reallocarray.c +++ b/malloc/tst-reallocarray.c @@ -22,6 +22,8 @@ #include #include +#include "tst-malloc-aux.h" + static void * reallocarray_nowarn (void *ptr, size_t nmemb, size_t size) {