This is the mail archive of the gcc-help@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]

Bad code generated with -mabi=ms?


I've noticed some oddities (well, my program crashes) compiling code
using the -mabi option of gcc 4.6.

Here's a test case:

int z(int i) { return i; }

If I compile it with:

gcc-4.6 -Os -m32 -mabi=sysv -o test.s -c test.c -S -fomit-frame-pointer

I get this (trimmed):

	movl	4(%esp), %eax
	ret

However, if I compile it with this:

gcc-4.6 -Os -m32 -mabi=ms -o test.s -c test.c -S -fomit-frame-pointer

I get this:

	movl	36(%esp), %eax
	ret

The -fomit-frame-pointer is there purely to make the output assembly
smaller; removing it has no effect. Compiling for amd64 with abi=ms
shows the same unusually large offsets, although as amd64 passes some
parameters in registers I need to change the test case for this.

By comparison, compiling the same test case using a copy of the mingw
compiler (based on gcc 4.4.4) produces an offset of 4. Visual C (which I
assume that -mabi=ms is supposed to interoperate with) does the same.

Any ideas as to what's going on here?

This is all using the version of gcc 4.6.3 that comes with Debian
(billed as Debian 4.6.3-1); it's hosted on an amd64 Debian box.

-- 
ââââ ïïïïïïïïïïïïïï âââââ http://www.cowlark.com âââââ
â "Parents let children ride bicycles on the street. But parents do not
â allow children to hear vulgar words. Therefore we can deduce that
â cursing is more dangerous than being hit by a car." --- Scott Adams

Attachment: signature.asc
Description: OpenPGP digital signature


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