[new test case jluu@mainsoft.com: Re: Possible linker problem]

Ian Lance Taylor ian@zembu.com
Wed Mar 15 09:46:00 GMT 2000


   From: "Jose Luu" <jluu@mainsoft.com>
   Date: Wed, 15 Mar 2000 14:02:41 +0100

   >-Bsymbolic is not a normal option, and it should not be treated as
   >such; -Bsymbolic is a special option used to speed up a shared
   >library.  We shouldn't compromise -Bsymbolic because we have found an
   >unusual case which it handles incorrectly.

   For us it is a normal option, because it is the behavior of the Windows
   linker, and all these Windows applications that we are porting to Linux
   needs it (for behavior rather than speed), especially the complex ones, like
   the gigantic professional CAD programs.

To the best of my knowledge, the Windows linker behaviour is not
analogous to -Bsymbolic.  Windows uses an explicit list of exports,
typically marked by __dllspec.  -Bsymbolic provides no control over
exported symbols (as you have discovered).  If you want to emulate the
Windows behaviour, you should be generating linker version scripts
from lists of exported symbols.

If you don't do this, you will run into trouble if some Windows DLL
has an exported function F and another Windows DLL has a non-exported
function with the same name F.  That will work fine under Windows, but
on Unix, if you rely on -Bsymbolic, it will behave unpredictably
depending upon the order in which the libraries are seen by the
linker.

-Bsymbolic means that all references in a shared library should be
satisfied first by symbols defined in that shared library.  Windows
has that behaviour, because the Windows notion of a shared library is
impoverished and requires special coding sequences to refer to symbols
defined outside the shared library.  However, Windows has additional
behaviour: the list of exported and imported symbols is explicitly
specified during the link process.  If you want to emulate Windows
properly, you must emulate that explicit specification.  When using
the GNU linker, the way to do that is via a version script.

Ian


More information about the Binutils mailing list