[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Global Symbols and Version Scripts




Dale,

Enclosed is a internal note that was sent to me which is LSB specific that
I am not sure about.  Could you or someone familiar with the "Shared
Libraries and Naming Conventions" portion of the LSB specification comment
on the note below?

Thanks,

George Kraft IV
gk4@us.ibm.com
512-838-2688; t/l 678-2688
IBM Linux Technology Center


Just a word to those developers about a unique Linux issue.

We have been developing a number of shared libs for our project. We have
found that if two shared libs have the same external symbols declared and
defined with them, then the first one loaded will be used for libraries
loaded later. For example, we have a shared lib with the declaration and
definition of the variable dgTrcExec which is a pointer to a variable
length structure of trace information for that shared lib. In a second
shared lib we again declare and define the same variable, dgTrcExec, to
point to a similar structure, but with a different number of entries for
that shared lib. What we have found is that if the first library is loaded,
and then the second lib is loaded, all references to the second's internal
dgTrcExec will refer to the variable in the first lib and not the one in
the second. As a result, the second library will reference the wrong
information or SIGSEGV is it references information beyond the end of the
variable length structure. Not nice!

So, how are we solving the problem... Because Linux exports all symbols by
default, the only way we have found to eliminate this problem is to make
these external symbols local, not global. [Naturally we could rename them
to be unique for each shared lib, but that was not an option]. To make them
local we defined a version script which lists each variable as local. For
example, the version script file fontmanagerld.vs contains: VERS_1.0 {
local: dgTrcExec; };

So to summarize, some operating system platforms, such as AIX, assume all
symbols are local and you must specify which are global using a export
file. Linux is the opposite. It assumes that all symbols are global and you
must specify which are local using a version script. As a result,
programming that is being ported over from AIX, can have radically
different behavior if you are not aware of differences such as this.

EOR



Reply to: