z/TPF Program Management - IBM
z/TPF Program Management - IBM
z/TPF Program Management - IBM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Archives<br />
Visibility in shared objects<br />
Archives are a collection of ELF objects that are link-edited into a shared object. If<br />
your calling program has an ARCHIVES:= statement coded in the associated<br />
makefile, the archives specified by the statement get link-edited into the shared<br />
object. This way, the link to the functions contained in the archive is static.<br />
Use archives if you have a library of functions that frequently change and you are<br />
interested in changing the functions themselves without impacting the application<br />
programming interfaces (APIs) contained in the shared object or the calling<br />
program. A tape library is an example of an archive. See “Create an archive for<br />
online programs” on page 67 and “Create an archive for offline Linux programs” on<br />
page 68 for more information about creating archives. See “Create an offline Linux<br />
program” on page 67 for an example of a program that calls functions in an archive.<br />
In the GNU compiler collection (GCC) environment, the term that is used for<br />
exporting is visibility. As it applies to functions and variables in a shared object,<br />
visibility refers to the ability of other shared objects to call a C/C++ function.<br />
Functions with default visibility have a global scope and can be called from other<br />
shared objects. Functions with hidden visibility have a local scope and cannot be<br />
called from other shared objects.<br />
Visibility can be controlled by using either compiler options or visibility attributes.<br />
The -fvisibility=default compiler option (used in conjunction with the<br />
-fvisibility inlines=default compiler option for C++ programs) is used to define<br />
all of the functions in a shared object as visible (global scope). These compiler<br />
options are available on all z/<strong>TPF</strong>-supported compilers. Adding the visibility attribute<br />
can override a compiler option.<br />
Using the z/<strong>TPF</strong> Make<strong>TPF</strong> tool makes it relatively easy to control the visibility of<br />
functions by changing the makefile to specify APP_EXPORT or to use the visibility<br />
attribute in the program.<br />
Make<strong>TPF</strong> and visibility<br />
The maketpf APP_EXPORT variable controls which functions are local to the shared<br />
object and which functions can be called from other shared objects, where<br />
APP_EXPORT can be set to: ALL, VISIBILITY, LIST, orENTRY.<br />
v ALL is used to make all functions visible by default at compile time, by adding the<br />
-fvisibility=default compiler option (used in conjunction with the<br />
-fvisibility inlines=default compiler option for C++ programs) to the compile<br />
commands. Individual functions can be hidden by using the visibility attribute; add<br />
__attribute__ ((visibility("hidden")) to the functions you want to hide.<br />
Note: Avoid adding __attribute__ ((visibility("hidden")) to C++ code<br />
unless it is essential for class member functions to be hidden. For more<br />
information about potential problems when you use visibility with C++<br />
classes, see “Special considerations for C++ classes” on page 15.<br />
v VISIBILITY is used to hide all functions by default at compile time, by adding the<br />
-fvisibility=hidden compiler option (used in conjunction with the -fvisibility<br />
inlines=hidden compiler option for C++ programs) to the compile commands.<br />
z/<strong>TPF</strong> program types and linkage 13