Bad code generated with -mabi=ms?
Ian Lance Taylor
iant@google.com
Tue Mar 20 16:45:00 GMT 2012
David Given <dg@cowlark.com> writes:
> 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.
I can recreate this problem with gcc 4.6, but not with gcc 4.7.
I think it's a bug in gcc 4.6 that was fixed by this patch:
http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01664.html
Ian
More information about the Gcc-help
mailing list