This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Feature request: Globalize symbol


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]