https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97461
--- Comment #25 from Richard Biener <rguenth at gcc dot gnu.org> --- How about allocating memory by other means (brk/mmap) instead? That is, run your own simple allocator? I suppose gcov never frees things (until the end) so it could be quite simple one? And fall back to static allocated counters for targets that we do not handle? Is there a command-line option to choose "static" counters? More possibilities involve libdl and dlsym to iterate to 'malloc' from a different shared object than the one profiled. Or on glibc platforms use __malloc instead of malloc (via alias). That said, using plain 'malloc' was a bad idea.