public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object
@ 2003-06-09 19:49 jcalcote@novell.com
2003-06-10 1:24 ` [Bug c++/11137] [3.3 Regression] " pinskia@physics.uc.edu
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: jcalcote@novell.com @ 2003-06-09 19:49 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
Summary: Linux shared library constructors not called unless
there's one global object
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: major
Priority: P2
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jcalcote@novell.com
CC: gcc-bugs@gcc.gnu.org
Linux shared library constructor and destructor routines defined by the use of
the __attribute__((constructor)) and __attribute__((destructor)) keywords are
not called in C++ programs when the library is loaded/unloaded unless there is
at least one global object in the module. Global constructors and destructors
appears to work correctly in C programs. Only C++ programs exhibit this
strange behaviour. I use the following hack to get my constructors to be
called - I place this statement in my init/exit code:
static struct Stupid { Stupid() {} ~Stupid() {} } stupid;
which causes Stupid() to be executed at library load time, and then adds a
call to my __attribute__((constructor)).
Having disassembled the code to my module by using objdump, I can see that the
routine that calls global object constructors is not injected unless there's
at least one global object. Since calls to __attribute__((constructor))
routines are placed at the end of this compiler generated code, no such calls
will be made if this code is not generated. The cause of generation of this
routine appears to be the existance of a global C++ object, but not the
existence of __attribute__((constuctor)) routines.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
@ 2003-06-10 1:24 ` pinskia@physics.uc.edu
2003-06-29 15:58 ` pinskia at physics dot uc dot edu
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: pinskia@physics.uc.edu @ 2003-06-10 1:24 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
pinskia@physics.uc.edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-06-10 01:24:28
date| |
Summary|Linux shared library |[3.3 Regression] Linux
|constructors not called |shared library constructors
|unless there's one global |not called unless there's
|object |one global object
Target Milestone|3.4 |3.3.1
------- Additional Comments From pinskia@physics.uc.edu 2003-06-10 01:24 -------
I could reproduce this on 2.95.2, 3.0.4, 3.2.2, 3.2.3, and 3.3.1 (20030526) but it is fixed on
the mainline (20030609) and it works on egcs-2.91.66, so this is a regression from that
which is a very old but still a regression.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
2003-06-10 1:24 ` [Bug c++/11137] [3.3 Regression] " pinskia@physics.uc.edu
@ 2003-06-29 15:58 ` pinskia at physics dot uc dot edu
2003-07-01 18:14 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-06-29 15:58 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
------- Additional Comments From pinskia at physics dot uc dot edu 2003-06-29 15:58 -------
I forgot to put the testcase I used:
pr11137.cc:
extern "C" int printf(const char*,...);
void f() __attribute__((constructor));
void f()
{
printf("Hi\n");
}
pr11137.1.cc:
int main() {return 0;}
gcc -shared -o pr11137.so pr11137.cc
gcc pr11137.1.cc pr11137.so
env LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH} ./a.out
It should be print "Hi" but it does not on 3.3.1 (20030616) because gcc does not create a
function which calls f() but 3.4 does.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
2003-06-10 1:24 ` [Bug c++/11137] [3.3 Regression] " pinskia@physics.uc.edu
2003-06-29 15:58 ` pinskia at physics dot uc dot edu
@ 2003-07-01 18:14 ` cvs-commit at gcc dot gnu dot org
2003-07-01 18:15 ` mmitchel at gcc dot gnu dot org
2003-08-12 14:14 ` cvs-commit at gcc dot gnu dot org
4 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-01 18:14 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-07-01 18:14 -------
Subject: Bug 11137
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: mmitchel@gcc.gnu.org 2003-07-01 18:14:34
Modified files:
gcc/cp : ChangeLog decl2.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/init: attrib1.C
Log message:
PR c++/11137
* decl2.c (generate_ctor_or_dtor_function): Tolerate a
non-existant ssdf_decls array.
(finish_file): Call generator_ctor_or_dtor_function when there are
static constructors or destructors and no other static
initializations.
PR c++/11137
* g++.dg/init/attrib1.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.171&r2=1.3076.2.172
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.31&r2=1.575.2.32
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.211&r2=1.2261.2.212
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/attrib1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.8.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
` (2 preceding siblings ...)
2003-07-01 18:14 ` cvs-commit at gcc dot gnu dot org
@ 2003-07-01 18:15 ` mmitchel at gcc dot gnu dot org
2003-08-12 14:14 ` cvs-commit at gcc dot gnu dot org
4 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-07-01 18:15 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From mmitchel at gcc dot gnu dot org 2003-07-01 18:15 -------
Fixed in GCC 3.3.1.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/11137] [3.3 Regression] Linux shared library constructors not called unless there's one global object
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
` (3 preceding siblings ...)
2003-07-01 18:15 ` mmitchel at gcc dot gnu dot org
@ 2003-08-12 14:14 ` cvs-commit at gcc dot gnu dot org
4 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-08-12 14:14 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11137
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-08-12 14:14 -------
Subject: Bug 11137
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_2-rhl8-branch
Changes by: jakub@gcc.gnu.org 2003-08-12 14:14:49
Modified files:
gcc : ChangeLog
gcc/cp : decl2.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/init: attrib1.C
Log message:
PR c++/11137
* decl2.c (generate_ctor_or_dtor_function): Tolerate a
non-existant ssdf_decls array.
(finish_file): Call generator_ctor_or_dtor_function when there are
static constructors or destructors and no other static
initializations.
PR c++/11137
* g++.dg/init/attrib1.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.13152.2.657.2.27.2.155&r2=1.13152.2.657.2.27.2.156
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.520.2.7.2.3.2.7&r2=1.520.2.7.2.3.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.1672.2.166.2.8.2.64&r2=1.1672.2.166.2.8.2.65
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/attrib1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.16.1
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <bug-11137-4@http.gcc.gnu.org/bugzilla/>]
end of thread, other threads:[~2010-11-16 17:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-09 19:49 [Bug c++/11137] New: Linux shared library constructors not called unless there's one global object jcalcote@novell.com
2003-06-10 1:24 ` [Bug c++/11137] [3.3 Regression] " pinskia@physics.uc.edu
2003-06-29 15:58 ` pinskia at physics dot uc dot edu
2003-07-01 18:14 ` cvs-commit at gcc dot gnu dot org
2003-07-01 18:15 ` mmitchel at gcc dot gnu dot org
2003-08-12 14:14 ` cvs-commit at gcc dot gnu dot org
[not found] <bug-11137-4@http.gcc.gnu.org/bugzilla/>
2010-11-16 17:57 ` hjl at gcc dot gnu.org
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).