Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 May 1998 16:19:04 +1000
From:      Stephen McKay <syssgm@dtir.qld.gov.au>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        freebsd-current@FreeBSD.ORG, syssgm@dtir.qld.gov.au
Subject:   Re: Fix for undefined "__error" and discussion of shared object versioning 
Message-ID:  <199805250619.QAA14093@troll.dtir.qld.gov.au>
In-Reply-To: <199805231951.MAA10260@usr07.primenet.com> from Terry Lambert at "Sat, 23 May 1998 19:51:36 %2B0000"
References:  <199805231951.MAA10260@usr07.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday, 23rd May 1998, Terry Lambert wrote:

>The weak symbol is apparently being screwed over by our linker *before*
>the libraries are examined for identical non-weak symbols.

>This is *WRONG*.  The ld program is *BROKEN*.

At this point then, someone else will have to pursue changes to ld proper,
as I have insufficient knowledge of ld and insufficient time to repair it.

>In the shared library case, the loading of shared objects and the
>resoloution of weak symbols is, in fact, correct.
>
>Practically, this means that the weak __error definition to ___error
>*WILL* work, but *ONLY* if it occurs in shared objects, and *NOT*
>in the main program.

Sorry, not true.  I've already done the experiment that shows that it
fails in shared objects too.  Allow me to cut and paste:

>> Output of ldd:
>> 
>> foo:
>> 	-l__error.0 => /syshome/syssgm/lib/lib__error.so.0.0 (0x20014000)
>> 	-lc_r.3 => /usr/lib/libc_r.so.3.0 (0x20019000)
>> 	-lc.3 => /usr/lib/libc.so.3.1 (0x2009b000)
>> -----------------------------------------------------------------------------
>> Output of foo:
>> -----------------------------------------------------------------------------
>> errno is 0
>> count is 1
>> errno is 21
>> count is 3
>> -----------------------------------------------------------------------------
>
>The problem here is that foo is getting the __error = ___error from
>foo.o, not from teh shared library.

I was not clear enough when packaging my previous message.  This version
of foo did not have your errno.h patch, and thus did not put your ___error
in foo.o.  The example shows that although libc_r and libc have __error,
it is instead linked from lib__error, simply because it is first, without
regard to weak or non-weak symbols.

>I would expect the strong __error in /usr/lib/libc_r.so.3.0 to override
>the weak __error = ___error in /syshome/syssgm/lib/lib__error.so.0.0

Unfortunately, this is not the case.

>[ ... hack to ld.so ... ]
>
>I'm anxious about this hack because what you are doing is covering a
>bug in ld that is interfering with your test case.  I think this can
>be adequately dispensed with by doing the right thing in errno.h
>and bsd.lib.mk.

It may be covering a defect in ld, but it's the best I can do right now.
I intend to polish my ld.so hack as time permits.  Eventually we have to
do something.

>> So, for the folks that really care about this, we now have 3 possible
>> options:
>> 
>> 1) back out the errno change, and possibly put it back after ELF.
>> 
>> 2) hack ld.so (prototype works fine)
>> 
>> 3) bump ALL library major numbers
>> 
>> Which will it be?
>
>There are two more:
>
>  4) hack errno.h to define the weak symbol mechanism I proposed, and
>     fix ld so that errno.h doesn't have to know that a shared library
>     compilation unit is including it.
>
>  5) hack errno.h to define the weak symbol mechanism I proposed, and
>     hack bsd.lib.mk that errno.h knows that a shared library
>     compilation unit is including it.

Is it likely that ld will be fixed?  I doubt that I will find time to
fix it, especially as Nate claims it is much harder than it looks.

>About 8 hours of work on ld could fix it.

Please finish it then.  Forget about USENET for a time!

Stephen.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805250619.QAA14093>