> I have found an apparent bug in gcc 3.4.4 under Cygwin. The attached test 
> case (and the code
> it's derived from) works as expected with Cygwin gcc 3.3.3 with the exact 
> same Cygwin install
> except the compiler packages. It also works fine with various versions of gcc 
> on other
> platforms, including 3.4.2 (FC3) and 4.0 (FC4).


Here is the reason:

When linking against the dll, you are notified:
Info: resolving typeinfo for base_t by linking to __imp___ZTI6base_t 
(auto-import)

typeinfo tables are readonly and so place in .rdata section.

Auto-import doesn't work for .rdata because it depends on the linker writing a 
thunk to
dereference the  *__imp__foo.  It gets away with this trickery for non-constant 
data by "casting"
the .text section writeable.  But the loader really does expect the contents of 
.rdata section to
be non-writeable. If you lie to it, bad things happen.

If we put readonly data in text section (as we did in gcc-3.3.x) then your 
testcase should work.

It will also work if you don't use auto-import and explicitly mark the 
dllimport'd base_t class
with __attribute__ ((dllimport)).

Danny

Send instant messages to your online friends http://au.messenger.yahoo.com 

Reply via email to