ITEM: AA2433L

hiding symbols in a shared library



Customer wants information on how to hide certain global variables
in the shared library. You have an option in DEC for the ld 
command to do this called -hidden_symbol. How can we do this
under AIX?

Response:

Symbols within a shared object are usable by all
the code within that object.  A symbol is only visible to an external
reference (from another object) if that symbol has been explicitly
exported.  If a symbol is not exported, then it is effectively hidden
to the outside "world."

Are there any tools that could be used to build a list
of exported symbols?

The following shell script generates a list of 
sorted symbols defined within a set of objects and/or archives that are 
listed on the command line.  The list is sent to stdout.

--------------------------------------------------------------------------
 \#!/bin/ksh
 \# @(\#)99        1.1  svnmall, hookld, binder325 12/8/93 14:37:22
 \#
 \#   COMPONENT_NAME: hookld
 \#
 \#   FUNCTIONS: none
 \#
 \#   ORIGINS: 27
 \#
 \#
 \#   (C) COPYRIGHT International Business Machines Corp. 1993
 \#   All Rights Reserved
 \#   Licensed Materials - Property of IBM
 \#   US Government Users Restricted Rights - Use, duplication or
 \#   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 \#
 \#
 \#       List all of the exportable, *defined* symbols in every object
 \#       file named on the command line.  Only use commands we trust
 \#
 \#       Origin: grh
 \#

 function        verifyCmd
 {
        if [ ! -f $1 ]
        then
                echo error: svnmall: command '$1' not found
        fi
 }

 GrepCmd=`whence egrep`
 if [ -z "$GrepCmd" ]
 then
        GrepCmd=`whence grep`
 else
        GrepCmd=/usr/bin/egrep
 fi

 DumpCmd=/usr/bin/dump
 verifyCmd $DumpCmd

 SortCmd=/usr/bin/sort
 verifyCmd $SortCmd

 UniqCmd=/usr/bin/uniq
 verifyCmd $UniqCmd

 CutCmd=/usr/bin/cut
 verifyCmd $CutCmd

 for file in $*
 do
        $DumpCmd -tv $file | $GrepCmd extern | $GrepCmd -v undef | \\
            $CutCmd -f2- | $CutCmd -c59- | $GrepCmd -v '\^.'
 done | $SortCmd | $UniqCmd
--------------------------------------------------------------------------


Support Line: hiding symbols in a shared library ITEM: AA2433L
Dated: June 1996 Category: N/A
This HTML file was generated 99/06/24~13:30:32
Comments or suggestions? Contact us