Newsgroups: comp.lang.c++
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!linus!linus!mir!dsr
From: dsr@mir.mitre.org (Douglas S. Rand)
Subject: Re: SunOS shared libraries and virtual tables
Message-ID: <1991Mar19.151044.4762@linus.mitre.org>
Sender: news@linus.mitre.org (News Service)
Nntp-Posting-Host: mir.mitre.org
Reply-To: dsr@mir.mitre.org (Douglas S. Rand)
Organization: The MITRE Corporation
References:  <68989@brunix.UUCP>
Date: Tue, 19 Mar 1991 15:10:44 GMT

In article <68989@brunix.UUCP>, gjb@cs.brown.edu (Gregory Brail) writes:
> In SunOS, one can make libraries "shared," which means their code in
> memory is shared between all processes that use them, and all those
> executables use the same file to get at the code. However, external
> initialized data (like global constants, for instance) cannot be
> shared. One can, however, manually put all external initialized data
> in a separate part of the library so it won't be shared and the rest
> of the library will be.
> 
> With C, this is easy. With C++, however, all virtual tables and
> pointers to virtual tables fall under the "external initialized data"
> category, or at least that's how I understand it.
> 
> Has anyone come up with a good way to solve this problem? One can just
> ignore the problem with virtual tables -- the shared libraries still
> work (although less efficiently). One could also use the +e0 and +e1
> arguments to cfront by creating one (or a few) files that contain just
> class definitions and putting those definitions in the non-shared part
> of the library. This, however, is a pain, and getting a few hundred
> class definitions into one file isn't easy, to say the least.
> 
> The shared version of libC that comes with Sun C++ appears to have the
> virtual tables in the sharable portion of the library. Is this the
> correct solution, or should one put the virtual tables in the
> non-shared portion? And if that's the case, what's the easiest way to
> do that?
> 
> Thanks in advance for the help.
> 
> 				-greg
> +----------------------------------------------------+
> Greg Brail
> Internet: gjb@cs.brown.edu  BITNET: gjb@browncs.bitnet
> UUCP:	..uunet!brunix!gjb  Home:   (401)273-1172

It's really pretty simple.  All read-only linkage can be shared.  Are
virtual tables apropriate for read-only linkage?  No run-time initialization?
If so they can be treated as any const declaration and put in the read-only
pure code space.  Otherwise they must go in a per-user read/write space.

Only in Unix is this a new debate.

-- 
Douglas S. Rand 
Internet:   <dsrand@mitre.org>
Snail:	    MITRE, Burlington Road, Bedford, MA 
Disclaimer: MITRE might agree with me - then again...
Amateur Radio: KC1KJ
