From: Ruediger Helsch <rh@unifix.de>
To: Ian Lance Taylor <ian@cygnus.com>
Cc: rms@gnu.ai.mit.edu, drepper@cygnus.com, dm@sgi.com,
gcc2@cygnus.com, gas2@cygnus.com
Subject: Re: global vars and symbol visibility for mips32/elf
Date: Tue, 13 Aug 1996 10:58:00 -0000 [thread overview]
Message-ID: <Pine.LNX.3.91.960813173031.26776I-100000@anna.unifix.de> (raw)
In-Reply-To: <9608110241.AA22482@tweedledumb.cygnus.com>
On Sat, 10 Aug 1996, Ian Lance Taylor wrote:
> The case which causes trouble is when a program uses a common variable
> (an uninitialized variable in C; most languages, including C++, have
> no notion of common variables). A common variable is treated as an
> undefined reference, unless no definition is seen. In the latter
> case, the common variable becomes a definition.
>
> When a common variable is used, the linker will resolve it against a
> definition found in a shared library. This is different from the
> handling of an archive library, at least in ELF. In an ELF archive
> library, a particular object will not be included in the link merely
> to satisfy a common reference; it will only be included to satisfy an
> undefined reference.
>
> In some cases, it will be desirable to resolve a common symbol with
> the definition in the shared library. This would be desirable when
> the actual intent was to use the initialized variable in the shared
> library. For example, if a program uses ``int optind;'' rather than
> ``extern int optind;'', and it also calls getopt, then, in both a
> shared library and an archive library, the common symbol optind will
> wind up referring to the initialized variable optind, rather than
> creating a new, uninitialized, optind variable.
Wrong. A standard conforming compiler will conclaim about a multiply
defined symbol.
This problem has been avoided by the C standard by forbidding COMMON
generation (ISO/IEC 9899:1990 6.7.2). Unfortunately GCC generates
commons even when -ansi is specified. In either case it is not
desirable to link commons against functions, which solves the problem
without disabling commons.
Ruediger Helsch <rh@unifix.de>
next prev parent reply other threads:[~1996-08-13 10:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-09 2:46 David S. Miller
1996-08-09 5:24 ` David S. Miller
1996-08-09 9:01 ` Ian Lance Taylor
1996-08-09 8:30 ` Ian Lance Taylor
1996-08-09 13:13 ` Ulrich Drepper
1996-08-09 15:30 ` Ian Lance Taylor
1996-08-10 17:37 ` Richard Stallman
1996-08-10 19:41 ` Ian Lance Taylor
1996-08-10 23:26 ` Jim Wilson
1996-08-11 1:44 ` Richard Stallman
1996-08-13 10:58 ` Ruediger Helsch [this message]
1996-08-13 13:36 ` Jim Wilson
1996-08-13 16:06 ` Ruediger Helsch
1996-08-13 19:04 ` Jim Wilson
1996-08-13 21:02 ` Richard Stallman
1996-08-14 3:06 ` Ruediger Helsch
1996-08-14 23:44 ` Richard Stallman
1996-08-14 0:18 ` Nick Ing-Simmons
1996-08-14 3:06 ` Ruediger Helsch
1996-08-15 11:24 ` H.J. Lu
1996-08-13 9:06 ` Ruediger Helsch
1996-08-13 10:58 ` Richard Stallman
1996-08-13 13:36 ` Ruediger Helsch
1996-08-13 13:36 ` Richard Stallman
1996-08-13 14:40 ` H.J. Lu
1996-08-13 16:06 ` Ulrich Drepper
1996-08-13 16:06 ` Joe Buck
1996-08-13 17:02 ` Rohan LENARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.3.91.960813173031.26776I-100000@anna.unifix.de \
--to=rh@unifix.de \
--cc=dm@sgi.com \
--cc=drepper@cygnus.com \
--cc=gas2@cygnus.com \
--cc=gcc2@cygnus.com \
--cc=ian@cygnus.com \
--cc=rms@gnu.ai.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).