public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Old gcc method parameter error
@ 2011-09-29 13:26 Fabian Cenedese
  2011-09-29 21:20 ` Ian Lance Taylor
  2011-09-30 20:31 ` Gunther Nikl
  0 siblings, 2 replies; 5+ messages in thread
From: Fabian Cenedese @ 2011-09-29 13:26 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-03 15:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29 13:26 Old gcc method parameter error Fabian Cenedese
2011-09-29 21:20 ` Ian Lance Taylor
2011-09-30 20:31 ` Gunther Nikl
2011-10-03  6:59   ` Fabian Cenedese
     [not found]   ` <mcrpqih3h80.fsf@coign.corp.google.com>
2011-10-03 15:03     ` Gunther Nikl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).