SPRAB89A September 2011 – March 2014
Only functions that can be called from another link unit need to adjust the DP. Functions that can be called only from within their static link unit do not need to adjust the DP, since they can rely on their caller to have done so. A function's ability to be externally called is known as its visibility. (Note that visibility also applies to an object's ability to be preempted; see Section 6.5.)
An external call from another link unit can be direct, in which case the function is called by name, or indirect, in which case the function's address is taken and passed to the external caller, who calls it through this address. ELF provides four levels of visibility, which cover various possibilities for direct and indirect calls from other modules as summarized in Table 6-1:
Name | Directly Callable | Indirectly Callable | Preemptable |
---|---|---|---|
STV_DEFAULT | yes | yes | yes |
STV_PROTECTED | yes | yes | no |
STV_HIDDEN | no | yes | no |
STV_INTERNAL | no | no | no |
A function's visibility is determined by a combination of its declaration and a set of compiler and platform specific conventions. For example, the Linux model is that an external function has STV_DEFAULT visibility unless otherwise indicated by augmenting its declaration with an _ _attribute_ _((visibility)) modifier; but for bare-metal platforms a default visibility of STV_HIDDEN or STV_INTERNAL may be more appropriate.