[Bug target/38085] gcc -m64 -pg generates invalid assembler code on Solaris 10/x86
bennett dot schneider at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 29 22:12:00 GMT 2009
------- 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.orig Wed 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
More information about the Gcc-bugs
mailing list