This is the mail archive of the
mailing list for the GCC project.
Re: Duplicate data objects in shared libraries
- From: "David Abrahams" <david dot abrahams at rcn dot com>
- To: "Mark Mitchell" <mark at codesourcery dot com>,"Jason Merrill" <jason at redhat dot com>
- Cc: "Martin v. Loewis" <martin at v dot loewis dot de>,"H . J . Lu" <hjl at lucon dot org>,<drepper at redhat dot com>,"Ralf W. Grosse-Kunstleve" <rwgk at cci dot lbl dot gov>,<gcc at gcc dot gnu dot org>
- Date: Mon, 20 May 2002 15:35:27 -0400
- Subject: Re: Duplicate data objects in shared libraries
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
- Reply-to: "David Abrahams" <david dot abrahams at rcn dot com>
From: "Mark Mitchell" <email@example.com>
> > I think that being able to write plugins in C++ is important, and a
> I guess I just don't think that using RTLD_LOCAL is the only reasonable
> way to do it.
If you are writing an application which loads plugins which may be written
in "C", it is pretty-much the only reasonable way to do it. Martin details
the reasons quite nicely here:
...and although namespaces mitigate things a bit, I think the arguments
still apply to C++.
> But, if there's a good solution here, we should definitely do it.
I just spent some more time discussing Jason's #5 solution with him, and
trying to find problems with it. We weren't able to find any; it does seem
to provide the desired semantics in all cases we could imagine with a
minimum of subtlety and complication.
One thing we didn't discuss in detail was what should happen in case two of
a library's dependencies are already loaded, each with its own definition
for some shared symbol S. There are two possiblities I can imagine:
1. Pick one
Unless we get a new symbol label which means "must be shared", I'm strongly
in favor of 1. In many cases there's no detectable difference when symbols
aren't actually shared (for example, inline functions with no static data
and which nobody takes the address of), and I don't want to make otherwise
legitimate uses fail. Even if we had a "must be shared" label, describing
how to implement suitably selective error reporting is not simple.