Following program
cat >test-pg-src.c <<EOF
#include<stdio.h>
int
main(int argc, char **argv)
{
 printf("argc: %d argv: %p\n", argc, argv);
 return 0;
}
EOF

compiled with "-pg" options
gcc -pg -o test-pg test-pg-src.c

results in following code (disassembled with mdb)

main:       leal   0x4(%esp),%ecx
main+4:     andl   $0xfffffff0,%esp
main+7:     pushl  -0x4(%ecx)
main+0xa:   pushl  %ebp
main+0xb:   movl   %esp,%ebp
main+0xd:   pushl  %ecx
main+0xe:   subl   $0x14,%esp
main+0x11:  movl   $0x8049ed0,%edx
main+0x16:  call   -0x5d3   <_mcount>
main+0x1b:  movl   0x4(%ecx),%eax  ; either _mcount should not change ecx
                                   ; or the compiler should restore ecx - 
                                   ; for example "movl 0x14(%esp), %ecx"
                                   ; (the number 0x14 is taken from the line
                                   ; "main+0xe: subl   $0x14,%esp")

main+0x1e:  movl   %eax,0x8(%esp)
main+0x22:  movl   (%ecx),%eax
main+0x24:  movl   %eax,0x4(%esp)
main+0x28:  movl   $0x8048d6c,(%esp)
main+0x2f:  call   -0x6c8   <printf>
main+0x34:  movl   $0x0,%eax
main+0x39:  addl   $0x14,%esp
main+0x3c:  popl   %ecx
main+0x3d:  popl   %ebp
main+0x3e:  leal   -0x4(%ecx),%esp
main+0x41:  ret    

After call to mcount register ecx is changed, but commands, following call to
mcount, assume the register ecx unchanged.


-- 
           Summary: mcount in gmon.o change register ecx
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: YLitvinenko at astana dot oilfield dot slb dot com
 GCC build triplet: i386-pc-solaris2.11
  GCC host triplet: i386-pc-solaris2.11
GCC target triplet: i386-pc-solaris2.11


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38239

  • [Bug c/38239] New: mco... YLitvinenko at astana dot oilfield dot slb dot com

Reply via email to