Feature request: Globalize symbol
James E Wilson
wilson@specifixinc.com
Thu Mar 10 22:41:00 GMT 2005
Fredrik Hugosson wrote:
> My proposal is the following new options:
> -fglobalize-symbol=SYMBOLNAME
> -fglobalize-symbols=FILENAME
> -fglobalize-all-symbols
It is unlikely someone will volunteer to implement a feature that only
you need.
Globalizing a symbol in a shared library is potentially unsafe, and that
may resulting in linker conflicts, or it may result in a shared library
variable being overriden by a variable in another module causing silent
changes in behaviour.
Another way to attack this problem would be to add accessor functions to
the shared libraries. Presumably you only need to be able to read/write
the variables, so an accessor function would solve this problem without
compiler changes. So if you have a variable
static int slib_var;
Add functions
int __unittest_read_slib_var (void) { return slib_var;}
void __unittest_set_slib_var (int value) { slib_var = value; }
to the shared library when you compile it.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list