DT_SYMBOLIC and -Bsymbolic

Eric Youngdale eric@aib.com
Tue Jun 20 11:55:00 GMT 1995

	OK, I think the enclosed patch is more along the lines of what is
required.  The general idea is that we bypass the PLT when -Bsymbolic is
in effect, and in addition the GOT slots have a different type of relocation
(R_*_RELATIVE instead of R_*_GLOB_DAT).  I updated both the Sparc and i386
backends (others would be easy, if other backends supported shared libs).

	From what I can tell the advantages of using this are that you
get slightly better performance at runtime since you do not go through the
PLT for every function call.  In addition, there is less startup overhead
since there are no PLT slots to be initialized.  The GOT slots still exist,
but the R_*_RELOCATION relocations do not have a symbol, so you do not
have to search any of the symbol tables to perform these relocations, and
there would be yet another very slight performance increase.

	The Solaris linker does put a DT_SYMBOLIC entry in the .dynamic
section, but I am not sure what it is used for.  It is possible that it
would be used in cases where you attempt to link non-PIC code into a
shared library, since you would still be emitting relocations to the
output file in this case.  Thus patches to the dynamic loader should still
be required.

	The drawbacks to using this flag are that the library is less
sharable.  In other words, the user cannot redefine functions in the
library and expect that their redefinition will work for calls to the
function from within the library.

	I vaguely recall a few months ago seeing a discussion between some
of the members of the ABI+ committee (who are charged with updating the
SVr4 ABI, and merging differences between Solaris and Unixware).  Apparently
some (but not all) SVr4 vendors are using -Bsymbolic with libc - apparently
for performance reasons.

	FWIW, I would recommend against ever using this switch except in
certain specific cases - people need to know exactly what they are doing
when they turn this one on, and they need to know the ramifications.


"The woods are lovely, dark and deep.  But I have promises to keep,
And lines to code before I sleep, And lines to code before I sleep."

More information about the Gas2 mailing list