I've come across an issue with using the -pg switch for profiling on the
DJGPP DOS platform, using GCC 4.1.0.  After some digging through
disassembly, I found that the part of the function prologue for main()
before the call to mcount() is using the ECX register, and the call to
the mcount() function appears to be clobbering it.  I've verified that
GCC 4.1.0 for Linux appears to work, and GCC 4.0.1 for DJGPP also works
fine.

Here's the assembly for the function prologue of main():

lea    0x4(%esp),%ecx
and    $0xfffffff0,%esp
pushl  0xfffffffc(%ecx)
push   %ebp
mov    %esp,%ebp
push   %ebx
push   %ecx
mov    $0x146e0,%edx
call   0x3890 <mcount>
mov    %ecx,%ebx         <--- clobbered value of ECX is used

And here's the relevant portion of mcount():

push   %ebp
mov    %esp,%ebp
push   %edi
push   %esi
push   %ebx
sub    $0x1c,%esp
mov    %edx,0xffffffec(%ebp)
mov    0x15ca0,%ecx      <--- ECX gets clobbered

So I'm trying to figure out what's changed; is there a new requirement
that ECX is not preserved that didn't exist before?  I've looked through
some GCC source but I'm really not at all sure what I should be looking
for.

TIA...

Reply via email to