Date: Sat, 11 May 2002 16:45:25 -0700 From: Alfred Perlstein <alfred@FreeBSD.org> To: Marcel Moolenaar <marcel@xcllnt.net> 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> In-Reply-To: <20020511183419.GA306@dhcp01.pn.xcllnt.net> References: <200205110813.g4B8Dgo23554@freefall.freebsd.org> <20020511081613.GG90188@elvis.mu.org> <20020511183419.GA306@dhcp01.pn.xcllnt.net>
next in thread | previous in thread | raw e-mail | index | archive | help
* Marcel Moolenaar <marcel@xcllnt.net> [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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020511234525.GM90188>