egcs+CYGWIN32 -- needs special linker help?
Mumit Khan
khan@xraylith.wisc.edu
Wed Oct 22 16:49:00 GMT 1997
I've been trying to get egcs to work with gnu-win32 b18 distributed by
Cygnus, and so far not having much luck. I can get the whole CDK to build
ok with egcs, but get tons of linker warnings (and resulting programs that
don't run under win32) when building cygwin.dll.
After looking thru cygwin32 target macros, one major change in the recent
snapshot since gnu-win32 beta 18 release is the addition of UNIQUE_SECTION
and UNIQUE_SECTION_P macros and also the use of ".linkonce" directive that
the PE linkers supposedly use to discard duplicates. Unfortunately this is
what's causing the warnings from the linker (v2.9 according to cdk/ld/NEWS)
when dealing with vtables.
Do I need a newer ld?
Here's a simple example:
==== foo.h
class foo {
public:
foo () { }
virtual ~foo ();
virtual int bar () const { return 0; }
};
==== foo.cc
#include "foo.h"
foo::~foo () { }
==== main.cc
#include "foo.h"
int main () {
foo foo1;
return 0;
}
====
If I now try to link these together, ld complains bitterly:
/scratch/src/gnuwin32/i386-cygwin32/bin/ld: foo.o: warning: duplicate
section `.data$_vt$3foo' has different size
/scratch/src/gnuwin32/i386-cygwin32/bin/ld: foo.o: warning: duplicate
section `.data$_vt$3foo' has different size
[... many many more ...]
Here's what nm says:
=== foo.o
0000002c b .bss
0000002c d .data
0000002c d .data$_vt$3foo <<<<<< .linkonce same_size
00000078 d .eh_frame
00000000 t .text
00000050 d .text$__tf3foo
00000044 d foo::.text$bar(void) const
00000000 T foo::~foo(void)
00000078 d __FRAME_BEGIN__
U __builtin_delete
00000004 C __eh_cleanup
00000004 C __eh_in_catch
00000004 C __eh_pc
00000004 C __eh_type
00000004 C __eh_value
00000000 t __gnu_compiled_cplusplus
U __rtti_user
00000050 D foo type_info function
00000008 C foo type_info node
0000002c D foo virtual table
00000044 D foo::bar(void) const
00000000 t gcc2_compiled.
=== main.o
00000064 b .bss
00000064 d .data
00000078 t .data$_vt$3foo <<<<<< .linkonce same_size
000000e8 t .eh_frame
000000c4 t .gcc_except_table
00000000 t .text
00000064 t foo::.text$(void)
0000009c t .text$__tf3foo
00000090 t foo::.text$bar(void) const
U foo::~foo(void)
00000064 T foo::foo(void)
000000dc t __EXCEPTION_END__
000000c4 t __EXCEPTION_TABLE__
000000e8 t __FRAME_BEGIN__
00000004 C __eh_cleanup
00000004 C __eh_in_catch
00000004 C __eh_pc
00000004 C __eh_type
00000004 C __eh_value
00000000 t __gnu_compiled_cplusplus
U __main
U __rtti_user
0000009c T foo type_info function
U __throw
00000008 C foo type_info node
00000078 T foo virtual table
00000090 T foo::bar(void) const
00000000 T main
U terminate(void)
00000000 t gcc2_compiled.
========
Looking at the generated assembly output, the sizes of data$_vt$3foo seems
to be the same, so I'm totally lost here.
Anybody know what might be going on?
Thanks in advance,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/
More information about the Gcc
mailing list