From am@amsoft.ru  Sun Sep  7 05:18:54 1997
Received: from amsoft.ru (amsoft.ru [194.87.86.241])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id FAA15500
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Sep 1997 05:18:21 -0700 (PDT)
Received: (from am@localhost) by amsoft.ru (8.8.5/amsoft/1.0)
	id OAA00849 ; Sun, 7 Sep 1997 14:46:47 +0400 (MSD)
Message-Id: <199709071046.OAA00849@amsoft.ru>
Date: Sun, 7 Sep 1997 14:46:47 +0400 (MSD)
From: Andrew Maltsev <am@amsoft.ru>
Reply-To: am@amsoft.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: dynamic loader design bug
X-Send-Pr-Version: 3.2

>Number:         4482
>Category:       misc
>Synopsis:       A bug in dynamic loader design
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jdp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep  7 05:20:01 PDT 1997
>Closed-Date:    Sun Apr 26 11:02:25 PDT 1998
>Last-Modified:  Sun Apr 26 11:06:39 PDT 1998
>Originator:     Andrew Maltsev
>Release:        FreeBSD 2.2-RELEASE i386
>Organization:
AM'SOFT
>Environment:

	

>Description:

 When dynamic loader places shered object into address space of an
 executable all symbols, which are presnet both in `main' executable and
 in loaded shared object, are resolved from `main'.

 It's a bug I think. They should be resolved first from object's
 internal symbols. And going deeper I think, that there should be a
 flag, by which clashed symbols in main and object should be rearranged
 to use object's ones after it's loading even if `main' has it's own
 ones. This will greatly simplify plug-in's development. Especially
 those plug-in's which are developed as a `bug-fixes' for large
 binary-distributed executables.

 Developer may say then to his customers 'just drop that bug fix into
 `bugfixes' directory and your ploblem will go away' -- nice and more
 and more demanded feature, I think.

>How-To-Repeat:

 unpack and say `make test'

begin 600 FreeBSD-dl-bug.tgz
M'XL(`)J%$C0``^V77T_;,!#`^QI_BEL!->W:D(2TD<JZ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>Fix:
	
 Don't know. It may be hard to fix or not - just don't know..

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jdp 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Sun Sep 14 12:35:30 PDT 1997 
Responsible-Changed-Why:  
Dynamic loader are John Polstra area. 
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Sun Apr 26 11:02:25 PDT 1998 
State-Changed-Why:  
The behavior your describe is not a bug.  It is intentional, and it 
is consistent with both ths SunOS and ELF dynamic linkers.  It also 
agrees with the behavior of static libraries.  If shared libraries 
resolved their symbols using different rules than static libraries, 
it would be very confusing. 

If you want a shared library to override symbols in the main program, 
you can achieve that using LD_PRELOAD.  See the man page for details. 

If you want a shared library to prefer its own symbols, you can use 
the "-Bsymbolic" flag when building the library.  See ld(1) for 
details. 
>Unformatted:
