Old gcc method parameter error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I have a problem with an old gcc 2.95.2. Before you say that I should update
I can tell you that we have a new gcc4.5 based toolchain. But we still need
to support existing projects that work with the old compiler.

This is a cross-compiled gcc for PowerPC-EABI (e.g. 603, 750 etc)

The problem is with the way the parameters are placed on the stack if there's
not enough space in the registers (r3-r10, f1-f8).

unsigned long MyClass::Func(unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4,
	unsigned long a5, unsigned long a6, unsigned long a7, unsigned long a8, double d, char* s)
{
	printf("Received string: '%s'.", s);
	return 0;
}

void MyClass::Func2()
{
	Func(1, 2, 3, 4, 5, 6, 7, 8, 9.9, "testing");
}

I'd expect that r3 would hold the 'this' pointer, r4-r10 would hold the first
seven arguments, f1 would hold the double value and a8 and the string
pointer would be passed on the stack as two consecutive values
(e.g. x+8 and x+12, x is some offset in the stack).

The problem is now that the caller exactly does the described thing,
but the called function expects a different layout on the stack. The
string pointer is read from x+16 where of course no useful value is
stored. It's as if it thinks that at x+12 should be the double value
which makes no sense as this would need 8 bytes anyway. If I take
out the double value from the argument list then the two values are
as expected.

This function and the call are in the same file so any compiler flag
(calling convention) would apply to both places.

Does this ring a bell? I already tried to look at the diff to gcc 2.95.3
to find if this may have been solved but I couldn't understand the
gcc internal termini. I can understand if nobody has interest in
compiler archeology but I thought I'd ask anyway.

Thanks

bye  Fabi



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux