Windows tools produce different binary files
Ian Caddy
ianc at goanna.iinet.net.au
Tue Sep 12 09:09:51 UTC 2006
Hi All,
Mick Davis and I have been working through the issue of the mingw gcc
(4.1.1) compiler (same executable) creating different output files on
Windows XP machines to Windows 2000 machines under the mingw
environment. We use the Coldfire cross compiler.
It has turned out to be a register optimisation problem. For some
reason on the Windows 2000 machines, the location of local variables on
the stack is placed in a different position to the XP built application.
We have narrowed it down to the way qsort functions between the 2
different OSes.
In our cut down example code that fails, we have 9 local variables. The
size of all the variables, except the first one is 4 bytes. The first
variable size is 2 bytes. In gcc (file gcc/cfgexpand.c) function
partition_stack_vars these variables are sorted based on size using
qsort. They are already sorted effectively.
On the XP machine, the order is unchanged (0(size2) ,1(size4) ,2(size4)
,3(size4) ,4(size4) ,5(size4) ,6(size4) ,7(size4) ,8(size4) ) , but on
the Win2K machine, the order is changed to 0,2,3,1,4,5,6,7,8.
I wrote a small problem which I compiled using mingw gcc and ran the exe
on both machines. It starts with an array of 9 values that are already
sorted with the first value of 2 and the rest of 4.
I get different results running it on the XP machine to the Win2K
machine, the same as our cross compiler problem, on the XP machine the
order is unchanged (0,1,2,3,4,5,6,7,8), but on the 2000 machine, the
index is now 0,2,3,1,4,5,6,7,8. It looks like there is a problem with
the underlying OS qsort which is being called through the msys enivronment.
Since our user base uses both Windows XP and Windows 2000, we need to
support both platforms with identical output results. We are currently
trying to put our own version of qsort into gcc, to see if this fixes
the problem.
regards,
Ian Caddy.
--
Ian Caddy
Goanna Technologies Pty Ltd
+61 8 9221 1860
More information about the users
mailing list