Bill Mahoney wrote:
This much I knew. However! Let me rephrase my question. Suppose I
compile something with -finstrument-functions and don't supply my own
function. The linker must resolve it to something, so I assumed that
there is an empty function (e.g. a "ret" with a global label on it)
somewhere in the runtime library source; otherwise "ld" would barf. Is
this not the case, and the linker is just supplying that silently, or what?
It depends on the target. glibc has an implementation which writes the
profiling data to a FIFO named in the environment variable
PCPROFILE_OUTPUT (otherwise a no-op if not set.) Other targets don't
provide anything:
$ gcc -finstrument-functions tc.c
/tmp/cc92y1eZ.o:tc.c:(.text+0x15): undefined reference to
`___cyg_profile_func_enter'
/tmp/cc92y1eZ.o:tc.c:(.text+0x28): undefined reference to
`___cyg_profile_func_exit'
/tmp/cc92y1eZ.o:tc.c:(.text+0x63): undefined reference to
`___cyg_profile_func_enter'
/tmp/cc92y1eZ.o:tc.c:(.text+0x85): undefined reference to
`___cyg_profile_func_exit'
collect2: ld returned 1 exit status
Brian