public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Hal Black <hablack@vt.edu>
To: binutils@sources.redhat.com
Subject: Re: [BUG] ld behavior varies for C++ static initializer depending on .a or .o input
Date: Sat, 12 Apr 2003 04:01:00 -0000	[thread overview]
Message-ID: <3E978F84.4050603@vt.edu> (raw)
In-Reply-To: <orhe95d4i4.fsf@free.redhat.lsd.ic.unicamp.br>

Alexandre Oliva wrote:
> On Apr 11, 2003, Hal Black <hablack@vt.edu> wrote:
> 
> 
>>But when linking .a files composed
>>of those .o files, static initializers are not called.
> 
> 
> And, if you look closer, you'll notice the object files that contain
> the initializers aren't linked in at all.  Which is perfectly fine,
> given that no symbols from it are referenced.  Maybe you want
> --whole-archive?
> 

Thanks Alexandre, for replying and the --whole-archive tip - it works 
great (has to be -Wl,-whole-archive when passed to g++, though, as noted 
on the man page).

I still believe this is a bug, however.  Even though there aren't any 
references to static intializers, there is an implicit reference to 
them.  When using .o files, there are no references either, but the 
static intializer is included in that case.  Why should it be different 
for a .a file with the same .o files in it?  Should .a files not be used 
for C++?

Perhaps the solution is to pass --whole-archive by default to ld when 
linking with g++.

But, at least there is a workaround.

Thanks also to Alan for the reference, I don't know how I missed that 
thread.

  reply	other threads:[~2003-04-12  4:01 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 [this message]
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
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=3E978F84.4050603@vt.edu \
    --to=hablack@vt.edu \
    --cc=binutils@sources.redhat.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).