Optimizing Itanium-Based Applications (May 2011)

Optimizing Itanium-Based Applications
15
#pragma hidden symbol[,symbol]
#pragma binding hidden
The symbols with the given name or names are specified as having hidden export class. If no symbols
are given with –Bhidden, all symbols, including those referenced but not defined in the translation
unit, are specified as having hidden export class. The #pragma binding hidden applies to all
globally-scoped symbols following the pragma, prior to the next #pragma binding. Hidden export
class implies that the symbols are not exported outside the load module. In an executable, unreferenced
hidden symbols are eliminated when +Oprocelim is specified.
The treatment by the compiler is otherwise the same as for -Bprotected, including the implicit
-Wl,aarchive_shared when there is no symbol list specified with -Bhidden.
-Bhidden_def
Marks locally (non-tentatively) defined symbols as having hidden export class. The optimizations discussed
under -Bhidden are applied to these symbols only. This can be used when system header files are not
included for shared library calls or data accesses. For fastest code, users should add the appropriate header
file includes, and compile with –Bhidden.
-Bdefault=symbol[,symbol]*
-Bdefault:filename
#pragma default_binding symbol[,symbol]
#pragma binding default
The given symbols are specified has having default export class. This means that the symbols can be
imported or exported outside the load module. For tentative symbols, the compiler uses the linkage
table for access. For function calls not local to the translation unit, the compiler saves and restores GP
around the call. However, any accesses to locally (non-tentatively) defined symbols are optimized as
described under -Bprotected. By default, all symbols have default export class. However, this
option can be used to override a global -Bprotected, -Bhidden, or -Bextern option for specific
symbols. For example, if most calls in a translation unit are resolved within the load module, the user
can specify -Bprotected followed by -Bdefault on the list of shared library symbols that are
accessed in the translation unit. The #pragma binding default applies to all globally-scoped
symbols following the pragma, prior to the next #pragma binding.
-Bextern[=symbol[,symbol]*]
-Bextern:filename
#pragma extern symbol[,symbol]
#pragma binding extern
Functionally, this option or pragma is similar to -Bdefault. However, it provides the additional hint
to the compiler that the symbols are likely to reside in a separate load module, and therefore that the
compiler should inline the import stub for the calls to these symbols. Specification of a locally-defined
symbol on the -Bextern option or pragma causes the compiler to mark that symbol with default
export class. Unlike -Bdefault, it also avoids any compile-time binding for this locally defined
symbol, which means that references to the symbol are through the linkage table and gp is saved and
restored around calls to the symbol. Moreover, as with other symbols specified with -Bextern, it
means that calls to the locally defined symbol go through an inlined import stub. Clearly, all of this
results in a performance penalty when accessing these symbols, so -Bextern should be used only for
those symbols that are expected to be external or preemptible.
When specified without a symbol list, -Bextern applies only to undefined and tentatively-defined
symbols. The #pragma binding extern applies to all globally-scoped symbols following the
pragma, prior to the next #pragma binding.