delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/10/28/16:20:32

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: egcs-1.1: i386 stdcall function codegen bug
28 Oct 1998 16:20:32 -0800 :
Message-ID: <Pine.SUN.3.93.981027223545.28077A-200000.cygnus.gnu-win32@modi.xraylith.wisc.edu>
Mime-Version: 1.0
To: egcs-bugs AT cygnus DOT com, gnu-win32 AT cygnus DOT com

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime AT docserver DOT cac DOT washington DOT edu for more info.

--1915750185-1360710587-909549652=:28077
Content-Type: TEXT/PLAIN; charset=US-ASCII


egcs version : release and mainline
binutils     : 2.9.1 and 980830 snapshots

There seems to be a i386 codegen bug that affects "stdcall" functions
returning anything larger than an integer.

For the following function,

  double __attribute__((stdcall))
  foo_local1 (double f) {
    return f;
  }

The assembly created (using -O2 -fomit-frame-pointer to cut noise), we
get the following. This causes the return value to be garbage unless
I comment out the "fstp" instruction. 

  .globl _foo_local1 AT 8
  _foo_local1 AT 8:
	  fldl 4(%esp)
	  fstp %st(0)		## <<<< offending instruction
	  ret $8

Interestingly, for a "cdecl" function, the fstp instruction is missing
and everything works as expected.

  double 
  foo_local2 (double f) {
    return f;
  }

  .globl _foo_local2
  _foo_local2:
	  fldl 4(%esp)		## <<<< no fstp instruction
	  ret

I'm attaching a trivial, but complete, test program that shows the 
problem.

Regards,
Mumit


--1915750185-1360710587-909549652=:28077
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="stdcall-bug.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine DOT SUN DOT 3 DOT 93 DOT 981027224052 DOT 28077B AT modi DOT xraylith DOT wisc DOT edu>
Content-Description: bug test case

I2luY2x1ZGUgPHN0ZGlvLmg+DQoNCiNkZWZpbmUgV0lOQVBJIF9fYXR0cmli
dXRlX18oKHN0ZGNhbGwpKQ0KDQpkb3VibGUgV0lOQVBJDQpmb29fbG9jYWwx
IChkb3VibGUgZikgew0KICByZXR1cm4gZjsNCn0NCg0KZG91YmxlIA0KZm9v
X2xvY2FsMiAoZG91YmxlIGYpIHsNCiAgcmV0dXJuIGY7DQp9DQoNCmludCAN
Cm1haW4gKCkgDQp7IA0KICBkb3VibGUgZjEsIGYyOw0KICBmMSA9IDUuMDsN
CiAgZjIgPSBmb29fbG9jYWwxIChmMSk7DQogIHByaW50ZiAoImZvb19sb2Nh
bDEgKCVmKSA9ICVmXG4iLCBmMSwgZjIpOw0KICBmMiA9IGZvb19sb2NhbDIg
KGYxKTsNCiAgcHJpbnRmICgiZm9vX2xvY2FsMiAoJWYpID0gJWZcbiIsIGYx
LCBmMik7DQogIHJldHVybiAwOw0KfQ0KDQo=
--1915750185-1360710587-909549652=:28077--
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019