From: Ian Lance Taylor <ian@airs.com>
To: Zack Weinberg <zack@codesourcery.com>
Cc: binutils@sources.redhat.com, black@ieee.org
Subject: Re: [BUG] ld behavior varies for C++ static initializer depending on .a or .o input
Date: Sun, 13 Apr 2003 23:15:00 -0000 [thread overview]
Message-ID: <m34r52dm58.fsf@gossamer.airs.com> (raw)
In-Reply-To: <87he92ngiz.fsf@egil.codesourcery.com>
Zack Weinberg <zack@codesourcery.com> writes:
> Ian Lance Taylor <ian@airs.com> writes:
>
> > Hal Black <black@ieee.org> writes:
> >> Yes. That's the desired behavior. If a developer were to develop a
> >> library with a static initializer with side-effects, it would be
> >> something that should be called whenever that library was used.
> >
> > No Unix linker has ever worked that way.
> >
> > Basically, you misunderstand how ld and ar work. If you feel that you
> > have been misled by existing documentation, please let us know so that
> > we can fix it.
>
> I'd like to point out that while this is true for static (.a)
> libraries, it is not true for shared (.so) libraries -- the linker
> generates DT_NEEDED entries for every shared library on the command
> line, whether or not they satisfy undefined symbols. Personally I
> consider this a bug.
I think that one is debatable. It's certainly true that shared
libraries and archive libraries don't work the same way; as you say,
one obvious difference is in fact the very one we are talking
about--all static initializers in a shared library are run, whether
they are required or not. There are a number of other
differences--only in simple case can you just replace a .a file with a
.so file.
I think the general attitude of linker implementors has been that if
you list a shared library on the command line, you must want it in
there. That is, a .so file is in that sense more like a .o file than
a .a file.
But I agree that it could be argued the other way. I don't know of
any ELF linker which does not generate a DT_NEEDED for a .so listed on
the command line, but perhaps there is one.
Ian
next prev parent reply other threads:[~2003-04-13 23:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-11 3:43 Hal Black
2003-04-11 4:47 ` Alexandre Oliva
2003-04-12 4:01 ` Hal Black
2003-04-12 5:43 ` Alexandre Oliva
2003-04-12 14:24 ` Hal Black
2003-04-12 16:52 ` Ian Lance Taylor
2003-04-12 18:01 ` Hal Black
2003-04-12 20:45 ` Alexandre Oliva
2003-04-13 2:11 ` Hal Black
2003-04-14 18:41 ` Alexandre Oliva
2003-04-13 22:55 ` Ian Lance Taylor
2003-04-13 23:07 ` Zack Weinberg
2003-04-13 23:15 ` Ian Lance Taylor [this message]
2003-04-13 23:26 ` Ulrich Drepper
2003-04-14 5:14 ` Hal Black
2003-04-14 5:30 ` Ian Lance Taylor
2003-04-11 8:16 ` Alan Modra
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=m34r52dm58.fsf@gossamer.airs.com \
--to=ian@airs.com \
--cc=binutils@sources.redhat.com \
--cc=black@ieee.org \
--cc=zack@codesourcery.com \
/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).