From owner-freebsd-amd64@FreeBSD.ORG Tue May 18 09:46:42 2004 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C22FD16A4CE for ; Tue, 18 May 2004 09:46:42 -0700 (PDT) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id C41E943D41 for ; Tue, 18 May 2004 09:46:40 -0700 (PDT) (envelope-from peter@evilpete.dyndns.org) Received: from fw.wemm.org (canning.wemm.org [192.203.228.65]) by canning.wemm.org (Postfix) with ESMTP id 912762A7EA for ; Tue, 18 May 2004 09:46:40 -0700 (PDT) (envelope-from peter@overcee.wemm.org) Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by fw.wemm.org (Postfix) with ESMTP id 1B234E29E for ; Tue, 18 May 2004 09:46:40 -0700 (PDT) (envelope-from peter@overcee.wemm.org) Received: from overcee.wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (8.12.11/8.12.11) with ESMTP id i4IGkdQw012995; Tue, 18 May 2004 09:46:39 -0700 (PDT) (envelope-from peter@overcee.wemm.org) Received: from localhost (localhost [[UNIX: localhost]]) by overcee.wemm.org (8.12.11/8.12.11/Submit) id i4IGkc9w012994; Tue, 18 May 2004 09:46:38 -0700 (PDT) (envelope-from peter) From: Peter Wemm To: freebsd-amd64@freebsd.org Date: Tue, 18 May 2004 09:46:38 -0700 User-Agent: KMail/1.6.1 References: <20040518050421.GA75633%till@score.is.tsukuba.ac.jp> <20040518070430.GA68449@cat.robbins.dropbear.id.au> In-Reply-To: <20040518070430.GA68449@cat.robbins.dropbear.id.au> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200405180946.38351.peter@wemm.org> cc: Tim Robbins cc: Till Plewe Subject: Re: profiling on amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2004 16:46:42 -0000 On Tuesday 18 May 2004 12:04 am, Tim Robbins wrote: > 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 > header are at fault here. Yes, profiling wasn't something on my radar at the time so I mostly ignored it while doing the early porting work. -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5