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).
This commit is contained in:
Adhemerval Zanella 2025-04-02 12:51:51 -03:00
parent 628d34afdc
commit 3fff436ecf
4 changed files with 8 additions and 0 deletions

View File

@ -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 */

View File

@ -25,6 +25,8 @@
#include <libc-pointer-arith.h>
#include <support/check.h>
#include "tst-malloc-aux.h"
typedef struct TestCase {
size_t size;
size_t alignment;

View File

@ -27,6 +27,7 @@
#include <support/check.h>
#include <support/xthread.h>
#include "tst-malloc-aux.h"
typedef struct TestCase {
size_t size;

View File

@ -22,6 +22,8 @@
#include <support/check.h>
#include <libc-diag.h>
#include "tst-malloc-aux.h"
static void *
reallocarray_nowarn (void *ptr, size_t nmemb, size_t size)
{