This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin 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]

Re: Bug: BSS segment in COFF files


> I suppose it's too early to call it non-standard without strong
> evidence. For now, you have found that it's somehow incompatible with
> ida and/or watcom linker, though i did test linking x.o with
> watcom-compiled test.obj using wlink and everything worked fine.

The solution is to use non-static variables only. The Watcom linker
will then link properly. I still think the file is non standard though.

Here is an example that shows the problem:

file a.c: (compile with gcc)
static int a;
void function1_(void)
{ a=123; }

file b.c: (compile with gcc)
static int b;
int function2_(void)
{ return b;}

file test.c: (compile with Watcom)
#include <stdio.h>
extern void _function1(void);
extern int _function2(void);
void main(void)
{
  _function1();
  printf("%d\n",_function2());
}

It will print 123 even if b was never given a value. This is because
a and b are linked to the same memory position. If the variables a and
b are public you will get the expected 0.

BTW, don't use -fno-common. If you do it, even non-static variables
are linked at the same memory position.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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