bug with -mflat on UltraSparc I

Yamamoto Hirotaka ymmt@is.s.u-tokyo.ac.jp
Sun May 10 16:07:00 GMT 1998


I found a bug in the current egcs which makes most programs
compiled for sparc processor with "-mflat" option do not
work correctly.

I have reported the same bug of gcc-2.8.1.

** EGCS version:
gcc version egcs-2.91.28 19980508 (gcc2 ss-980502 experimental)

** Complete input file: (under the name of "foo.c")
/* CUT HERE */
#include <stdio.h>

int main (int argc)
{
  printf("%d\n", argc);
  return 0;
}
/* CUT HERE */

** Command Arguments:
% gcc -mflat -o foo foo.c

** Machine Type:
Sun Enterprise 4000 (consists of 14 UltraSparc I processors)
running Solaris2.5.1.

** Description of the bug:
The above command will produce a program "foo", which should
report the number of arguments passed to itself.
If no "-mflat" option is specified, it is OK, "foo" correctly
reports the number of arguments.
But with "-mflat" option, "foo" always returns 0, apparently
this is wrong!

I examined the assembler code generated by gcc-2.8.1 and egcs
and found their handling of registers wrong.  With "-mflat"
execution model, a function should receive its arguments from
registers %o0, %o1, %o2, ... instead of ordinary %i0, %i1, %i2,
...  But the produced assembler code sticked to receive
arguments from %i0, %i1, %i2, ...!

-- 
Hirotaka Yamamoto (ymmt@is.s.u-tokyo.ac.jp)
Yonezawa Laboratory, Department of Information Science,
Faculty of Science, University of Tokyo, Japan.



More information about the Gcc-bugs mailing list