gprof's broken in 7-CURRENT

Luoqi Chen Luoqi.Chen at brion.com
Tue Nov 27 19:31:54 PST 2007


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


More information about the freebsd-current mailing list