This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported
- From: "dannysmith at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Aug 2004 21:06:41 -0000
- Subject: [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Recent changes to dllexport handling in C++ frontend has broken
the use of dllexport attribute with multiple inheritance.
Now (gcc version 3.5.0 20040806 (experimental)) the dllexport attribute
causes some symbols *not* to be exported.
Here is a testcase:
// dll-mi.C
#ifdef BUILDING_DLL
#define DLL_IMPEXP __attribute__ ((dllexport))
#else
#define DLL_IMPEXP
#endif
class DLL_IMPEXP MBase
{
public:
virtual int vf() const = 0;
virtual ~MBase();
};
class DLL_IMPEXP D1 : virtual public MBase
{
public:
int vf() const;
};
MBase::~MBase(){}
int D1::vf() const { return 1; }
D:\develop\BUGS -shared -DBUILDING_DLL -o test.dll dll-mi.C
D:\TEMP/ccueaaaa.o(.rdata$_ZTV2D1+0x18):dll-mi.C: undefined reference to
`D1::~D1()'
D:\TEMP/ccueaaaa.o(.rdata$_ZTV2D1+0x1c):dll-mi.C: undefined reference to
`D1::~D1()'
And looking at the assembler, the compiler puts those dtors into the
vtable for D1
.globl __ZTV2D1
.section .rdata$_ZTV2D1,"dr"
.linkonce same_size
.align 32
__ZTV2D1:
.long 0
.long 0
.long 0
.long 0
.long __ZTI2D1
.long __ZNK2D12vfEv
.long __ZN2D1D1Ev
.long __ZN2D1D0Ev
.text
but doesn't actually emit the code for the two dtor's.
However if I build an object _without_ the dllexport, the dtor's
_ZN2D1D1Ev and _ZN2D1D0Ev (as well as thunks to these dtors) are
emitted. Here is the diff of two compiles without and with the dllexport
attribute enabled. The file dll-mi-no-export.s was built without the export
attribute, the other with:
> diff -up dll-mi-no-export.s dll-mi-export.s
D:\develop\BUGS>diff -up dll-mi-no-export.s dll-mi-export.s
--- dll-mi-no-export.s Mon Aug 09 08:30:35 2004
+++ dll-mi-export.s Mon Aug 09 08:30:41 2004
@@ -165,124 +165,15 @@ LCFI13:
leave
ret
LFE6:
- .section .text$_ZTv0_n16_N2D1D1Ev,"x"
- .linkonce discard
- .align 2
-.globl __ZTv0_n16_N2D1D1Ev
- .def __ZTv0_n16_N2D1D1Ev; .scl 2; .type 32; .endef
-__ZTv0_n16_N2D1D1Ev:
- movl 4(%esp), %eax
- movl (%eax), %ecx
- addl -16(%ecx), %eax
- movl %eax, 4(%esp)
- jmp __ZN2D1D1Ev
- .section .text$_ZN2D1D1Ev,"x"
- .linkonce discard
- .align 2
-.globl __ZN2D1D1Ev
- .def __ZN2D1D1Ev; .scl 2; .type 32; .endef
-__ZN2D1D1Ev:
-LFB9:
- pushl %ebp
-LCFI14:
- movl %esp, %ebp
-LCFI15:
- subl $8, %esp
-LCFI16:
- movl $__ZTV2D1+20, %eax
- movl 8(%ebp), %edx
- movl %eax, (%edx)
- movl 8(%ebp), %eax
- movl %eax, -4(%ebp)
- movl $0, %eax
- movl -4(%ebp), %edx
- addl %eax, %edx
- movl $__ZTV2D1+20, %eax
- movl %eax, (%edx)
- movl $2, %eax
- shrl %eax
- andl $1, %eax
- testb %al, %al
- je L15
- movl 8(%ebp), %edx
- movl %edx, -4(%ebp)
- subl $12, %esp
- pushl -4(%ebp)
-LCFI17:
- call __ZN5MBaseD2Ev
- addl $16, %esp
-L15:
- movl $0, %eax
- testb %al, %al
- je L14
- subl $12, %esp
- pushl 8(%ebp)
- call __ZdlPv
- addl $16, %esp
-L14:
- leave
- ret
-LFE9:
- .section .text$_ZTv0_n16_N2D1D0Ev,"x"
- .linkonce discard
- .align 2
-.globl __ZTv0_n16_N2D1D0Ev
- .def __ZTv0_n16_N2D1D0Ev; .scl 2; .type 32; .endef
-__ZTv0_n16_N2D1D0Ev:
- movl 4(%esp), %eax
- movl (%eax), %ecx
- addl -16(%ecx), %eax
- movl %eax, 4(%esp)
- jmp __ZN2D1D0Ev
- .section .text$_ZN2D1D0Ev,"x"
- .linkonce discard
- .align 2
-.globl __ZN2D1D0Ev
- .def __ZN2D1D0Ev; .scl 2; .type 32; .endef
-__ZN2D1D0Ev:
-LFB10:
- pushl %ebp
-LCFI18:
- movl %esp, %ebp
-LCFI19:
- subl $8, %esp
-LCFI20:
- movl $__ZTV2D1+20, %eax
- movl 8(%ebp), %edx
- movl %eax, (%edx)
- movl 8(%ebp), %eax
- movl %eax, -4(%ebp)
- movl $0, %eax
- movl -4(%ebp), %edx
- addl %eax, %edx
- movl $__ZTV2D1+20, %eax
- movl %eax, (%edx)
- movl $3, %eax
- shrl %eax
- andl $1, %eax
- testb %al, %al
- je L20
- movl 8(%ebp), %edx
- movl %edx, -4(%ebp)
- subl $12, %esp
- pushl -4(%ebp)
-LCFI21:
- call __ZN5MBaseD2Ev
- addl $16, %esp
-L20:
- movl $1, %eax
- testb %al, %al
- je L19
- subl $12, %esp
- pushl 8(%ebp)
- call __ZdlPv
- addl $16, %esp
-L19:
- leave
- ret
-LFE10:
- .def __ZTv0_n16_N2D1D0Ev; .scl 3; .type 32; .endef
- .def __ZTv0_n16_N2D1D1Ev; .scl 3; .type 32; .endef
- .def __ZTv0_n12_NK2D12vfEv; .scl 3; .type 32; .endef
.def ___cxa_pure_virtual; .scl 3; .type 32; .endef
.def __ZdlPv; .scl 3; .type 32; .endef
+ .section .drectve
+
+ .ascii " -export:_ZNK2D12vfEv"
+ .ascii " -export:_ZTv0_n12_NK2D12vfEv"
+ .ascii " -export:_ZN5MBaseD0Ev"
+ .ascii " -export:_ZN5MBaseD1Ev"
+ .ascii " -export:_ZN5MBaseD2Ev"
+ .ascii " -export:_ZTV2D1,data"
+ .ascii " -export:_ZTT2D1,data"
+ .ascii " -export:_ZTV5MBase,data"
--
Summary: dllexport attribute now causes some symbols _not_ to be
exported
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dannysmith at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924