bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU/Linker and Microsoft object code.


From: Pascal Obry
Subject: GNU/Linker and Microsoft object code.
Date: Tue, 19 Jun 2001 22:32:03 +0200

Binutils under Windows 2k.

Here is a report about a problem with GNU/Ld and Microsoft object codes. The
problem has been reproduced with:

       Compiler is GCC 2.8.1 MINGW32 
       GNAT 3.15w (an internal wavefront using new binutils).
       Binutils 2.10.91 and 2.11.90
       MSVC 6.x and MSVC 7.x (Microsoft Visual Studio .NET beta1)

Description:
------------

It seems that when .o (GNU object code) and .obj (Microsoft object code) are
mixed together some sections are overlaping (not sure it is the right name). I
mean that data section from .o and data section from .obj are using the same
address space for some variables.

How to reproduce:
-----------------

I have not been able yet to reproduce this problem with plain C code. Yet it
is quite easy to reproduce that with GNU/Ada compiler using binutils 2.10.91
or 2.11.90 and a Microsoft compiler MSVC 6.x or 7.x. Here is a very simple
piece of code:

[Ada code]
<<
procedure Vsimple is

   procedure C_Simple;
   pragma Import (C, C_Simple);
   --  Import C routine named c_simple

begin
   C_Simple; --  just call the C routine
end Vsimple;
>>

[C code]
<<
#include <stdio.h>

int u = 0;
int c = 0;

void
c_simple (void)
{
  printf ("local C = %d\n", c);
}
>>

To build:

$ cl /c /MD c_vsimple.c
$ gnatmake vsimple -largs c_vsimple.obj
$ ./vsimple
local C = 1

Here of course C should be 0 !

The final link command is:

$ gcc b~vsimple.o ./vsimple.o c_vsimple.obj -g -o vsimple.exe -L./ 
-Ld:/usr/gnat/lib/gcc-lib/pentium-mingw32msv/2.8.1/adalib/ 
d:/usr/gnat/lib/gcc-lib/pentium-mingw32msv/2.8.1/adalib/libgnat.a

If we move around the c_vsimple.obj we change the C value. For example by
putting c_vsimple.obj at the very end:

$ gcc b~vsimple.o ./vsimple.o -g -o vsimple.exe -L./ 
-Ld:/usr/gnat/lib/gcc-lib/pentium-mingw32msv/2.8.1/adalib/ 
d:/usr/gnat/lib/gcc-lib/pentium-mingw32msv/2.8.1/adalib/libgnat.a c_vsimple.obj 

we have the right answer:

$ ./vsimple
local C = 0

Of course if the C code is compiled with GCC there is no problem at all and we
have lot of tests in this direction. So I really believe that there is
something going wrong with the linker. It is also good to note that this
simple problem works fine if the C code is compiled with MSVC 4.x. Something
has changed in object code format after MSVC 4.X ???

Something else I have experienced, if the value of variable c (in the C code)
is set to something else than 0 then the right value is displayed.

I understand that this report is certainly not very easy to handle since you
don't have a way to reproduce this bug yourself... The problem is that I don't
have been able to reproduce this problem with plain C code...

Do you know of some bug in this area ? Is there some similar reports ? Any
idea about where the problem could come from ? I'm ready to try anything.

Let me know if you need some more information ?

Pascal Obry.
Ada Core Technologies.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]