, , --wrap ld ( gcc -Wl).
, --wrap ld "" ; , --wrap=malloc, ld __wrap_malloc, `malloc.
, --wrap=malloc __wrap_malloc, , , - malloc, .
$ cat test-nomalloc.c
#include <stdlib.h>
int main() {
#ifdef USE_MALLOC
malloc(10);
#endif
return 0;
}
$ gcc test-nomalloc.c -Wl,--wrap=malloc
$ gcc test-nomalloc.c -DUSE_MALLOC -Wl,--wrap=malloc
/tmp/ccIEUu9v.o: In function `main':
test-nomalloc.c:(.text+0xa): undefined reference to `__wrap_malloc'
collect2: error: ld returned 1 exit status
new _Znwm (operator new(unsigned long)) _Znam (operator new[](unsigned long)), , new.