[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-devtools
Subject:    HPUX-DEVTOOLS: shared libs.. hiding symbols..
From:       Anil Kumar Mudumbe <mudumbe () informix ! com>
Date:       1999-03-31 18:34:30
[Download RAW message or body]



Hi,

I need to "hide" symbols in a shared library from
say the "main" executable and from other shared libs..

The -Bsymbolic option for building the shared library
does not seem to hide symbols which are explicitly referenced in
the shared library.. 

The -h symbol works fine.. however is there something like
a -h "all" .. Something along the lines of the Solaris -Bsymbolic 
option.. Giving each and every symbol by hand with -h is cumbersome and its
possible that the global vars being re-defined are not even known at
build time.. 

Any hints appreciated..

Here is a scenario..


Thanks,
Anil


-------------------
gvar is the variable being "re-defined" unknowingly by the shared library..
its clobbering the gvar defined in main..

--------------- main.c
int gvar = 731 ;

main ()
{

 printf  ("gvar in main before shlib call %d\n", gvar) ;
 func_in_sharedlib() ;
 printf  ("gvar in main after shlib call %d\n", gvar) ;

}
---------------

---------------shlib.c
int gvar  ;

func_in_sharedlib()
{
 gvar = -920 ;
 printf ("gvar in shlib libfunc.sl = %d\n", gvar) ;

}
------------------


cc -c +Z shlib.c 
ld -b -o libfunc.sl shlib.o
cc main.c -L. -lfunc


----------
$ a.out
gvar in main before shlib call 731
gvar in shlib libfunc.sl = -920
gvar in main after shlib call -920
----------------

------------------
$ ld -Bsymbolic -b -o libfunc.sl shlib.o
$ a.out
gvar in main before shlib call 731
gvar in shlib libfunc.sl = -920
gvar in main after shlib call -920

----------------------
$ ld -h gvar -b -o libfunc.sl shlib.o   
$ a.out
gvar in main before shlib call 731
gvar in shlib libfunc.sl = -920
gvar in main after shlib call 731


 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE hpux-devtools
 _________________________________________________________________

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic