public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported
@ 2004-08-08 21:06 dannysmith at users dot sourceforge dot net
2004-08-08 22:04 ` [Bug c++/16924] [3.5 Regression] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-08-08 21:06 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
@ 2004-08-08 22:04 ` pinskia at gcc dot gnu dot org
2004-08-11 17:30 ` mmitchel at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-08 22:04 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org
Severity|normal |critical
Keywords| |wrong-code
Summary|dllexport attribute now |[3.5 Regression] dllexport
|causes some symbols _not_ to|attribute now causes some
|be exported |symbols _not_ to be exported
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
2004-08-08 22:04 ` [Bug c++/16924] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-11 17:30 ` mmitchel at gcc dot gnu dot org
2004-08-11 22:55 ` dannysmith at users dot sourceforge dot net
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-11 17:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-08-11 17:30 -------
Created an attachment (id=6916)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6916&action=view)
Patch to winnt.c
Danny --
The problem is that winnt.c is creating SYMBOL_REFs that do not have
SYMBOL_REF_DECL set correctly. That's been a latent bug since SYMBOL_REF_DECL
went in, but some of my changes have made it manifest in your test case. Would
you please test my patch? If it works out, I'll commit it.
Thanks,
-- Mark
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mmitchel at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
2004-08-08 22:04 ` [Bug c++/16924] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-11 17:30 ` mmitchel at gcc dot gnu dot org
@ 2004-08-11 22:55 ` dannysmith at users dot sourceforge dot net
2004-08-12 16:15 ` mark at codesourcery dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-08-11 22:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dannysmith at users dot sourceforge dot net 2004-08-11 22:55 -------
Thanks, Mark.
It does fix the regression, and cause no new failures.
config/sh/symbian.c and mcore/mcore.c also need similar patch
Should, the SYMBOL_REF_DECL also be set when encode_section_info
overrides a prior dllimport declaration with a new declaration without
the attribute, like so?
*** winnt.c.mm Thu Aug 12 07:36:01 2004
--- winnt.c Thu Aug 12 09:13:41 2004
*************** i386_pe_encode_section_info (tree decl,
*** 453,459 ****
/* Remove DLL_IMPORT_PREFIX. */
tree idp = get_identifier (oldname + strlen (DLL_IMPORT_PREFIX));
! rtx newrtl = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
if (DECL_INITIAL (decl) || !DECL_EXTERNAL (decl))
warning ("%J'%D' defined locally after being "
--- 453,465 ----
/* Remove DLL_IMPORT_PREFIX. */
tree idp = get_identifier (oldname + strlen (DLL_IMPORT_PREFIX));
! rtx symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
! SYMBOL_REF_DECL (symref) = decl;
! XEXP (DECL_RTL (decl), 0) = symref;
! DECL_NON_ADDR_CONST_P (decl) = 0;
!
! /* We previously set TREE_PUBLIC and DECL_EXTERNAL.
! We leave these alone for now. */
if (DECL_INITIAL (decl) || !DECL_EXTERNAL (decl))
warning ("%J'%D' defined locally after being "
*************** i386_pe_encode_section_info (tree decl,
*** 461,473 ****
else
warning ("%J'%D' redeclared without dllimport attribute "
"after being referenced with dllimport linkage", decl, decl);
-
- XEXP (DECL_RTL (decl), 0) = newrtl;
-
- DECL_NON_ADDR_CONST_P (decl) = 0;
-
- /* We previously set TREE_PUBLIC and DECL_EXTERNAL.
- We leave these alone for now. */
}
}
--- 467,472 ----
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
` (2 preceding siblings ...)
2004-08-11 22:55 ` dannysmith at users dot sourceforge dot net
@ 2004-08-12 16:15 ` mark at codesourcery dot com
2004-08-13 1:24 ` cvs-commit at gcc dot gnu dot org
2004-08-13 1:29 ` dannysmith at users dot sourceforge dot net
5 siblings, 0 replies; 7+ messages in thread
From: mark at codesourcery dot com @ 2004-08-12 16:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2004-08-12 16:15 -------
Subject: Re: [3.5 Regression] dllexport attribute now causes
some symbols _not_ to be exported
dannysmith at users dot sourceforge dot net wrote:
>------- Additional Comments From dannysmith at users dot sourceforge dot net 2004-08-11 22:55 -------
>Thanks, Mark.
>
>It does fix the regression, and cause no new failures.
>
>
Good.
>config/sh/symbian.c and mcore/mcore.c also need similar patch
>
>
Probably so.
>Should, the SYMBOL_REF_DECL also be set when encode_section_info
>overrides a prior dllimport declaration with a new declaration without
>the attribute, like so?
>
>
Yes.
I'm sorta suspicious of the NT port for needing to do this; I kinda
think that some other approach (involving SYMBOL_REF_FLAGS and overring
ASM_OUT_*) would be more reliable.
Will you please check in your patch together with mine?
Thanks,
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
` (3 preceding siblings ...)
2004-08-12 16:15 ` mark at codesourcery dot com
@ 2004-08-13 1:24 ` cvs-commit at gcc dot gnu dot org
2004-08-13 1:29 ` dannysmith at users dot sourceforge dot net
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-13 1:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-13 01:24 -------
Subject: Bug 16924
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: dannysmith@gcc.gnu.org 2004-08-13 01:24:28
Modified files:
gcc : ChangeLog
gcc/config/i386: winnt.c
Log message:
PR c++/16924
* config/i386/winnt.c (i386_pe_mark_dllexport): Set
SYMBOL_REF_DECL.
(i386_pe_mark_dllimport): Likewise.
(i386_pe_encode_section_info): Likewise, when overriding
dllimport attribute.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4890&r2=2.4891
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/winnt.c.diff?cvsroot=gcc&r1=1.69&r2=1.70
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16924] [3.5 Regression] dllexport attribute now causes some symbols _not_ to be exported
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
` (4 preceding siblings ...)
2004-08-13 1:24 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-13 1:29 ` dannysmith at users dot sourceforge dot net
5 siblings, 0 replies; 7+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2004-08-13 1:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dannysmith at users dot sourceforge dot net 2004-08-13 01:29 -------
Fixed by Mark's patch.
Danny
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16924
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-08-13 1:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-08 21:06 [Bug c++/16924] New: dllexport attribute now causes some symbols _not_ to be exported dannysmith at users dot sourceforge dot net
2004-08-08 22:04 ` [Bug c++/16924] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-11 17:30 ` mmitchel at gcc dot gnu dot org
2004-08-11 22:55 ` dannysmith at users dot sourceforge dot net
2004-08-12 16:15 ` mark at codesourcery dot com
2004-08-13 1:24 ` cvs-commit at gcc dot gnu dot org
2004-08-13 1:29 ` dannysmith at users dot sourceforge dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).