[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In the following discussion, we use the term "executable" to refer to either an application or a shared library of either type.
There are two ways a function can be called: either directly, or when its address is taken and a call is subsequently made through that pointer. An executable can construct a pointer to a function within itself, or to a function in a GLib it uses (this will really be a pointer to the relevant stub), but not to a SysLib or operating system API function (since you can't construct a pointer to a systrap).
In simple cases, access to globals isn't a major problem:
However, the situation gets more complex when an executable constructs a pointer to a function and then gives it to someone else, perhaps by passing it as an argument or by returning it to its caller. "Someone else" may be either another executable or the operating system (so the pointer is a "callback function").
The rules here are:
In previous versions of prc-tools, applications also accessed their globals via
the A4 register, and their function pointers were therefore subject to the
same restrictions as shared library function pointers. The appropriate steps
to initialise the global pointer are much simpler for an application than a
shared library, and were available via the macros CALLBACK_PROLOGUE
and CALLBACK_EPILOGUE
. This is no longer necessary. However,
if you really want to use `-mown-gp' when building an application,
you can use APP_ENTRYPOINT
as a more convenient equivalent of the
CALLBACK_*
macros.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |