This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Broken parameter offset in ColdFire v4/v4e port of gcc-3.0.4



I'm trying to get my ColdFire port of gcc-3.0.4 up and running and I'm
running into trouble with the -fomit-frame-pointer code.

In the process of building _vformat, I find that the offset to access
the parameters passed in is off by 4.  This is either due to the
initial fsize passed to the prologue is incorrect, or the offsets from
the %sp to access the values are wrong, but this only occurs when I'm
compiling for v4, not 5200.

The function opening looks like:

int _vformat (void (*putsub)(char c, char **p), 
              char **putbuf, const char *fmt, va_list argp)
{
  char c;
  int charcount = 0;
  char fillc;
  int maxwidth, width;
  int i, k;
  char *cp;
  char s[512];
  Boolean rj, splat, sign, blank, its_long, its_short;


  cp = s+NUMBUF;

  for (;;) {
    c = *fmt++;

And here's the generated code for -m5200/-m68000:


	.stabs	"putsub:p(0,23)=*(0,24)=f(0,20)",160,0,0,572
	.stabs	"putbuf:p(0,25)=*(0,26)=*(0,2)",160,0,0,576
	.stabs	"fmt:p(0,27)=*(0,2)",160,0,0,580
	.stabs	"argp:p(1,2)",160,0,0,584
	.globl	_vformat
	.type	_vformat,@function
_vformat:
	.stabn 68,0,86,.LM1-_vformat
.LM1:
	lea (-524,%sp),%sp
	lea (-44,%sp),%sp
	movm.l #0x7cfc,(%sp)
.LBB2:
	move.l 580(%sp),%a4


At .LBB2, %sp is adjusted down by 524+44=568 from the call, so at
offset 568 + 4(for the return address) = 572. Add 8 to skip the first
two parameters, and the offset if 'fmt' is 580(%sp) which matches the
instruction to load fmt into %a4.

When I build for -mcfv4/-mcfv4e (The 'e' has an FPU):

	.stabs	"putsub:p(0,23)=*(0,24)=f(0,20)",160,0,0,580
	.stabs	"putbuf:p(0,25)=*(0,26)=*(0,2)",160,0,0,584
	.stabs	"fmt:p(0,27)=*(0,2)",160,0,0,588
	.stabs	"argp:p(1,2)",160,0,0,592
	.globl	_vformat
	.type	_vformat,@function
_vformat:
	.stabn 68,0,86,.LM1-_vformat
.LM1:
	lea (-572,%sp),%sp
	movem.l #0x7cfc,(%sp)
.LBB2:
	move.l 588(%sp),%a4

At .LBB2 %sp is adjusted down 572 from the call, so at offset 572 +
4(for the return address) = 576 is the first parameter. Add 8 to skip
the first two parameters and the offset of 'fmt' is 584(%sp) which
*does not* match the instruction to load fmt to %a4.  Given the
prologue code, each of the accesses to paramters is off by +4...

Does anybody have any suggestions what I should look for in my port
code that is selectively executed based on the target_flags that
can change either the initial fsize, or the offsets for accessing
parameters? 

Any other suggestions on how to debug this?

Thanks in advance for any help!

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]