From owner-freebsd-current@FreeBSD.ORG Sun Nov 25 22:23:01 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DFF816A417 for ; Sun, 25 Nov 2007 22:23:01 +0000 (UTC) (envelope-from luoqi@luoqi.homeunix.org) Received: from luoqi.homeunix.org (c-76-102-199-51.hsd1.ca.comcast.net [76.102.199.51]) by mx1.freebsd.org (Postfix) with ESMTP id 250D013C44B for ; Sun, 25 Nov 2007 22:23:00 +0000 (UTC) (envelope-from luoqi@luoqi.homeunix.org) Received: from luoqi.homeunix.org (localhost [127.0.0.1]) by luoqi.homeunix.org (8.14.2/8.14.2) with ESMTP id lAPLsMkD003967 for ; Sun, 25 Nov 2007 13:54:22 -0800 (PST) (envelope-from luoqi@luoqi.homeunix.org) Received: (from luoqi@localhost) by luoqi.homeunix.org (8.14.2/8.14.2/Submit) id lAPLsMXb003966 for current@freebsd.org; Sun, 25 Nov 2007 13:54:22 -0800 (PST) (envelope-from luoqi) Date: Sun, 25 Nov 2007 13:54:22 -0800 (PST) From: Luoqi Chen Message-Id: <200711252154.lAPLsMXb003966@luoqi.homeunix.org> To: current@freebsd.org X-Mailman-Approved-At: Sun, 25 Nov 2007 23:43:47 +0000 Cc: Subject: gprof's broken in 7-CURRENT X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Nov 2007 22:23:01 -0000 Has anyone else noticed that gprof no longer works with gcc 4.2 compiled code? It has something to do with forced stack alignment. Here's the cc -O -S output of this piece of code: int main(int argc, char **argv) { if (argc < 2) exit(1); } .globl main .type main, @function main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp subl $56, %esp movl %ecx, -16(%ebp) movl %ebx, -12(%ebp) movl %esi, -8(%ebp) movl %edi, -4(%ebp) call .mcount movl 4(%ecx), %edi cmpl $2, (%ecx) jg .L83 movl $1, (%esp) call exit .p2align 4,,7 .L83: Register %ecx becomes the new ap after the forced stack alignment, however it is not preserved by .mcount. We can work around this problem by preserving ecx in mcount, but a better solution would be to fix gcc instead. -lq