public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* [rms@gnu.ai.mit.edu: Re: global vars and symbol visibility for mips32/elf]
@ 1996-08-21 11:19 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 1996-08-21 11:19 UTC (permalink / raw)
  To: gas2, bfd

I'm not wholly convinced that this is a good idea, but I am convinced
that I'm not going to have time to think about it.  Could somebody
volunteer to try an implementation of this, and see that it solves the
problem (I can describe it) and find out how it affects the speed?
Thanks.

Ian

------- Start of forwarded message -------
Date: Sun, 11 Aug 1996 04:44:10 -0400
From: Richard Stallman <rms@gnu.ai.mit.edu>
To: ian@cygnus.com
Cc: drepper@cygnus.com, dm@sgi.com, gcc2@cygnus.com, gas2@cygnus.com
In-Reply-To: < 9608110241.AA22482@tweedledumb.cygnus.com > (message from Ian
	Lance Taylor on Sat, 10 Aug 96 22:41:36 EDT)
Subject: Re: global vars and symbol visibility for mips32/elf

    If a shared library defines a function foo, and your program defines a
    function foo, that does not cause any conflict.  Your program's
    definition of foo is used.  If functions in the shared library call
    foo, they will call your program's definition of foo rather than the
    shared library's definition.  In this sense, shared libraries act just
    like archive libraries.

This is not, in general, what archive libraries do.  Archive libraries
do this in the common case where each defined global is in a separate
member.  But if one member defines two different globals, the archive
library does not work this way.  It is good practice, in most
situations, to put each global definition into a separate member, but
it is not universal practice.

If one member defines two global symbols X and Y, you can have a
program which links with no complaint against the shared library, but
would get an error if linked against the archive library.  All the
program needs to do is reference X and define Y as weak.  The archive
library would define Y and thus override the weak definition from the
program.  The shared library would, I expect, let the program override
Y's definition.

I think we should make the shared library work just like the archive
in all cases.

What is needed is a table of implications:
  If symbol foo is referenced, treat symbol bar as strong.
  If symbol bar is referenced, treat symbol foo as strong.
  If symbol quux is referenced, treat symbols foo and bar as strong.
  ...

(In that example, I've assumed that one member defines both foo and
bar, while another member defines quux and references foo.)

This table would selectively override the default behavior, which is
the same as now (each defined global symbol in the shared library acts
as weak).

Given this table, there would be no need to do anything special for
common symbols.  A common symbol in the library could be treated just
like any other definition in the library: use it to resolve an
undefined reference, or if forced by the table due to a reference to
some other symbol.

I don't think this would make linking much slower.  I think it could
be made quite fast by means of a table that parallels the main symbol
table in the library, so that you reference it using the same index
used in the main symbol table, rather than by looking up names,
------- End of forwarded message -------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-08-21 11:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-21 11:19 [rms@gnu.ai.mit.edu: Re: global vars and symbol visibility for mips32/elf] Ian Lance Taylor

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).