[Bug target/38085] gcc -m64 -pg generates invalid assembler code on Solaris 10/x86
--- Comment #2 from bennett dot schneider at yahoo dot com 2009-07-29 22:11 --- I've seen the same behaviour and was able to fix two separate issues. First, the @ symbol on the leaq instruction is not necessary. This code is being inserted because NO_PROFILE_COUNTERS is not defined ( See x86_function_profiler in http://gcc.gnu.org/viewcvs/trunk/gcc/config/i386/i386.c?revision=150062). After fixing the assembly, the programs compile successfully, but crash on execution. This seems to be related to code in the assembly header of _mcount http://gcc.gnu.org/viewcvs/trunk/gcc/config/i386/gmon-sol2.c?revision=138078 The original code as copied from glibc doesn't match the present contents. In particular: diff -u gcc/config/i386/gmon-sol2.c.orig gcc/config/i386/gmon-sol2.c --- gcc/config/i386/gmon-sol2.c.origWed Jul 29 08:57:15 2009 +++ gcc/config/i386/gmon-sol2.c Wed Jul 29 16:44:36 2009 @@ -266,8 +266,8 @@ "\tmovq\t%r9,0x30(%rsp)\n" /* Get SELFPC (pushed by the call to this function) and FROMPCINDEX (via the frame pointer. */ -"\tmovq\t0x38(%rsp),%rdi\n" -"\tmovq\t0x8(%rbp),%rsi\n" +"\tmovq\t0x38(%rsp),%rsi\n" +"\tmovq\t0x8(%rbp),%rdi\n" "\tcallq\tinternal_mcount\n" /* Restore the saved registers. */ "\tmovq\t0x30(%rsp),%r9\n" @@ -275,7 +275,7 @@ "\tmovq\t0x20(%rsp),%rdi\n" "\tmovq\t0x18(%rsp),%rsi\n" "\tmovq\t0x10(%rsp),%rdx\n" -"\tmovq\t0x08(%rsp),%rdx\n" +"\tmovq\t0x08(%rsp),%rcx\n" "\tmovq\t(%rsp),%rax\n" "\taddq\t$0x38,%rsp\n" "\tretq\n" After making this change, executables produce gmon.out, but I'm not sure the output is completely correct. The call graph output is correct (the parents and children seem to be reversed), so there may also be descrepancies in internal_mcount. -- bennett dot schneider at yahoo dot com changed: What |Removed |Added ------------ CC||bennett dot schneider at ||yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38085
[Bug target/38085] gcc -m64 -pg generates invalid assembler code on Solaris 10/x86
--- Comment #3 from bennett dot schneider at yahoo dot com 2009-07-30 13:06 --- internal_mcount's from and self arguments were reversed from glibc's version. Here's the full diff of gmon-sol2.c that produces correct output: --- gcc/config/i386/gmon-sol2.c.origWed Jul 29 08:57:15 2009 +++ gcc/config/i386/gmon-sol2.c Thu Jul 30 07:53:16 2009 @@ -66,7 +66,7 @@ extern void _mcleanup (void); extern void internal_mcount ( #ifdef __x86_64__ -char *, unsigned short * +unsigned short *, char * #else void #endif @@ -266,8 +266,8 @@ "\tmovq\t%r9,0x30(%rsp)\n" /* Get SELFPC (pushed by the call to this function) and FROMPCINDEX (via the frame pointer. */ -"\tmovq\t0x38(%rsp),%rdi\n" -"\tmovq\t0x8(%rbp),%rsi\n" +"\tmovq\t0x38(%rsp),%rsi\n" +"\tmovq\t0x8(%rbp),%rdi\n" "\tcallq\tinternal_mcount\n" /* Restore the saved registers. */ "\tmovq\t0x30(%rsp),%r9\n" @@ -275,7 +275,7 @@ "\tmovq\t0x20(%rsp),%rdi\n" "\tmovq\t0x18(%rsp),%rsi\n" "\tmovq\t0x10(%rsp),%rdx\n" -"\tmovq\t0x08(%rsp),%rdx\n" +"\tmovq\t0x08(%rsp),%rcx\n" "\tmovq\t(%rsp),%rax\n" "\taddq\t$0x38,%rsp\n" "\tretq\n" @@ -290,8 +290,8 @@ void internal_mcount ( #ifdef __x86_64__ -char *selfpc, -unsigned short *frompcindex +unsigned short *frompcindex, +char *selfpc #else void #endif -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38085