I've built MinGW- Cygwin and Linux hosted i686-pc-linux-gnu targeted cross
compiler tool chain from GCC 4.0.0 and binutils 2.16. 

The following tailored source code compiled by GCC 4.0.0 by these tool-chains
generates different assembly sources:

--- test.c ----
typedef unsigned char   byte;
typedef int             __i32;

#pragma pack(8)

typedef struct PHY_t {
    unsigned char drive;
    unsigned int  side;
    unsigned int  cylinder;
    unsigned int  sector;
} PHY_t;

#pragma pack()

__i32 VSKmain ( __i32   HEADSHIFT )
{
    byte virusboot[4096];
    PHY_t cim;

    if ( HEADSHIFT != -1 )
    {
        cim.side = virusboot[ HEADSHIFT ];
    }
    else
    {
        cim.side = 0;
    }
}
---- test.c ----

$ diff -udbB test3-cygwin/test.s test3-winnt/test.s
--- test3-cygwin/test.s 2005-08-11 20:36:11.621272000 +0200
+++ test3-winnt/test.s  2005-08-11 20:36:32.715832000 +0200
@@ -10,7 +10,7 @@
        cmp     DWORD PTR [%ebp+8], -1
        je      .L2
        mov     %eax, DWORD PTR [%ebp+8]
-       mov     %al, BYTE PTR [%ebp-4096+%eax]
+       mov     %al, BYTE PTR [%eax-4096+%ebp]
        movzx   %eax, %al
        mov     DWORD PTR [%ebp-4108], %eax
        jmp     .L6

This minor and neglible difference itself does not worry me in general, but I
would like to know what makes this difference if all cross-GCC was configured
and invoked by the same way.
I must ensure that each binary (.o files) are compatible with each other and
behaves the very same way regardless of the host compilation platform.

GCC logs on Cygwin:
-------------------
Target: i686-pc-linux-gnu
Configured with: ../../gcc-4.0.0/configure --verbose --prefix=/opt/vifc/vskc
--target=i686-pc-linux-gnu --enable-languages=c --disable-win32-registry
--disable-threads --disable-nls --disable-shared --disable-debug
--disable-multilib --disable-libmudflab --with-gcc --with-gnu-ld --with-gnu-as
--with-stabs --without-headers
Thread model: single
gcc version 4.0.0
 /opt/vifc/vskc/libexec/gcc/i686-pc-linux-gnu/4.0.0/cc1.exe -E -quiet -v test.c
-masm=intel -mtune=pentiumpro -W -Wall -fpch-preprocess -o test.i
ignoring nonexistent directory
"/opt/vifc/vskc/lib/gcc/i686-pc-linux-gnu/4.0.0/include"
ignoring nonexistent directory "/opt/vifc/vskc/i686-pc-linux-gnu/sys-include"
ignoring nonexistent directory "/opt/vifc/vskc/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 /opt/vifc/vskc/libexec/gcc/i686-pc-linux-gnu/4.0.0/cc1.exe -fpreprocessed
test.i -quiet -dumpbase test.c -masm=intel -mtune=pentiumpro -auxbase-strip
test.o -W -Wall -version -o test.s
GNU C version 4.0.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.3 (cygwin special).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64446
test.c: In function 'VSKmain':
test.c:28: warning: control reaches end of non-void function
 /opt/vifc/vskc/i686-pc-linux-gnu/bin/as.exe -V -Qy -o test.o test.s
GNU assembler version 2.16 (i686-pc-linux-gnu) using BFD version 2.16 


GCC logs on Win2k (MinGW compiled):
-----------------------------------
i686-pc-linux-gnu-gcc.exe: X:/vdbcomp/vskc/include: No such file or directory
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc-4.0.0/configure --verbose --prefix=X:/vifc/vskc
--target=i686-pc-linux-gnu --enable-languages=c --disable-threads --disable-nls
--disable-shared --disable-debug --with-gcc --with-gnu-ld --with-gnu-as
--with-stabs --without-headers --disable-win32-registry --disable-multilib
Thread model: single
gcc version 4.0.0
 x:/vifc/vskc/bin/../libexec/gcc/i686-pc-linux-gnu/4.0.0/cc1.exe -E -quiet -v -I
../vdbhome -I ../vdbhome/template -I -I -iprefix
x:\vifc\vskc\bin\../lib/gcc/i686-pc-linux-gnu/4.0.0/ -D__VDBCOMP__ test.c
-masm=intel -mtune=pentiumpro -W -Wall -fpch-preprocess -o test.i
ignoring nonexistent directory
"x:/vifc/vskc/bin/../lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/sys-include"
ignoring nonexistent directory
"x:/vifc/vskc/bin/../lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory
"X:/vifc/vskc/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/sys-include"
ignoring nonexistent directory
"X:/vifc/vskc/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "../vdbhome"
ignoring nonexistent directory "../vdbhome/template"
ignoring nonexistent directory "-I"
#include "..." search starts here:
#include <...> search starts here:
 x:/vifc/vskc/bin/../lib/gcc/i686-pc-linux-gnu/4.0.0/include
 X:/vifc/vskc/lib/gcc/i686-pc-linux-gnu/4.0.0/include
End of search list.
 x:/vifc/vskc/bin/../libexec/gcc/i686-pc-linux-gnu/4.0.0/cc1.exe -fpreprocessed
test.i -quiet -dumpbase test.c -masm=intel -mtune=pentiumpro -auxbase-strip
test.o -W -Wall -version -o test.s
GNU C version 4.0.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.2 (mingw-special).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64446
test.c: In function 'VSKmain':
test.c:28: warning: control reaches end of non-void function
 
x:/vifc/vskc/bin/../lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/bin/as.exe
--traditional-format -V -Qy -o test.o test.s
GNU assembler version 2.16 (i686-pc-linux-gnu) using BFD version 2.16

-- 
           Summary: minor difference in assembly code on different cross-
                    compilers
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gypapp at virusbuster dot hu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23339

Reply via email to