From owner-cvs-all Sat May 11 16:45:31 2002 Delivered-To: cvs-all@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 12F4837B405; Sat, 11 May 2002 16:45:26 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id DE49FAE03F; Sat, 11 May 2002 16:45:25 -0700 (PDT) Date: Sat, 11 May 2002 16:45:25 -0700 From: Alfred Perlstein To: Marcel Moolenaar Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libc_r/uthread Makefile.inc uthread_autoinit.c uthread_autoinit.cc Message-ID: <20020511234525.GM90188@elvis.mu.org> References: <200205110813.g4B8Dgo23554@freefall.freebsd.org> <20020511081613.GG90188@elvis.mu.org> <20020511183419.GA306@dhcp01.pn.xcllnt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020511183419.GA306@dhcp01.pn.xcllnt.net> User-Agent: Mutt/1.3.27i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Marcel Moolenaar [020511 11:34] wrote: > > > > Something is bizarro wrt __weak_reference and static linking, anyone > > have any ideas? > > Can you be more specific? > > It also helps to post a simple program that demonstrates the > the "bizarro" behaviour. Basically what is working for the -shared case is not working for the -static case. If you link a program static the 'constructor' method is not called. (uthread_autoinit.c) If you link static and explicitly reference something in the object that has the constructor then the constructor gets called. (call something in uthread_autoinit.c) However if you link dynamically then you can have a __weak_reference in libc that can be overridden by symbols in libc_r which will force bringing in the constructor. If you want to play with the brokenness then just do this: add a call: write(2, "\n\nblahblah\n\n", 12); to src/lib/libc_r/uthread/uthread_autoinit.c then link a program statically against libc_r and dynamically, only the dynamically linked version will emit the above output. However if you explicitly call the init function in uthread_autoinit.c from the static version it will get run twice. That is bizarro. :) -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message