gperftools documentation says that libprofiler
should be linked into a target program:
$ gcc myprogram.c -lprofiler
(without changing a code of the program).
And then program should be run with a specific environment variable:
CPUPROFILE=/tmp/profiler_output ./a.out
The question is: how does libprofile
have a chance to start and finish a profiler when it is merely loaded, but its functions are not called?
There is no constructor function in that library (proof). All occasions of "CPUPROFILE" in library code do not refer to any place where profiler is started.
I am out of ideas, where to look next?