profiling on amd64
Tim Robbins
tim at robbins.dropbear.id.au
Tue May 18 00:29:18 PDT 2004
On Tue, May 18, 2004 at 02:04:21PM +0900, Till Plewe wrote:
>
> The program "int main(){return 0;}" fails to compile if I use the
> option "-pg". The error message I get starts with:
>
> # gcc -pg -o test test.c
> /var/tmp//ccTPXtQI.o: In function `main':
> /var/tmp//ccTPXtQI.o(.text+0x5): undefined reference to `mcount'
> /usr/lib/libc_p.a(gmon.po): In function `monstartup':
> gmon.po(.text+0xa): undefined reference to `mcount
> ...
This is a bug in the FreeBSD/x86-64 GCC configuration. It should be
calling ``.mcount'' instead of ``mcount'' (note the full-stop at
the start of the name.) After applying this patch, rebuilding gcc,
and rebuilding the profiled C library, gcc -pg does not cause
linker errors:
==== //depot/user/tjr/freebsd-tjr/src/contrib/gcc/config/i386/freebsd64.h#5 - /home/tim/p4/src/contrib/gcc/config/i386/freebsd64.h ====
@@ -25,6 +25,9 @@
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (FreeBSD/x86-64 ELF)");
+#undef MCOUNT_NAME
+#define MCOUNT_NAME ".mcount"
+
#undef FBSD_TARGET_CPU_CPP_BUILTINS
#define FBSD_TARGET_CPU_CPP_BUILTINS() \
do \
However, programs compiled with -pg will crash almost immediately.
I don't understand why this happens well enough to venture
an explanation, but I think both GCC and FreeBSD/amd64's
<machine/profile.h> header are at fault here.
Tim
More information about the freebsd-amd64
mailing list