From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18503 invoked by alias); 12 Apr 2003 04:01:08 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 18495 invoked from network); 12 Apr 2003 04:01:08 -0000 Received: from unknown (HELO mail.hal.cx) (68.32.53.147) by sources.redhat.com with SMTP; 12 Apr 2003 04:01:08 -0000 Received: from vt.edu (unknown [192.168.0.108]) by mail.hal.cx (Postfix) with ESMTP id 22BDC2EE12 for ; Sat, 12 Apr 2003 00:01:08 -0400 (EDT) Message-ID: <3E978F84.4050603@vt.edu> Date: Sat, 12 Apr 2003 04:01:00 -0000 From: Hal Black User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030328 X-Accept-Language: en,pdf,ja MIME-Version: 1.0 To: binutils@sources.redhat.com Subject: Re: [BUG] ld behavior varies for C++ static initializer depending on .a or .o input References: <3E9639F9.9050503@vt.edu> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-04/txt/msg00279.txt.bz2 Alexandre Oliva wrote: > On Apr 11, 2003, Hal Black 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.