|
|
|
@ -4064,6 +4064,426 @@ xml:id="dbdoclet.50655240_pgfId-1156194">
|
|
|
|
|
requirements. Some tools may not work with alternate calling sequences
|
|
|
|
|
and conventions.</para>
|
|
|
|
|
</note>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_FnLinkage" revisionflag="added">
|
|
|
|
|
<title>Function Call Linkage Protocols</title>
|
|
|
|
|
<para>
|
|
|
|
|
The compiler (or assembly programmer) and linker cooperate to make
|
|
|
|
|
function calls as efficient as possible. Different protocols are
|
|
|
|
|
required depending on whether a call is local, whether the caller
|
|
|
|
|
and/or callee use a TOC pointer in r2 for code or data accesses
|
|
|
|
|
(see <xref linkend="dbdoclet.50655241_66700" />), and whether the
|
|
|
|
|
caller and/or callee guarantee to preserve r2. A local
|
|
|
|
|
function call is one where the callee is known and visible within
|
|
|
|
|
the unit of code being compiled or assembled. A function that
|
|
|
|
|
uses a TOC pointer always has a separate local entry point (see
|
|
|
|
|
<xref linkend="dbdoclet.50655240___RefHeading___Toc377640597" />),
|
|
|
|
|
and preserves r2 when called via its local entry point. See <xref
|
|
|
|
|
linkend="dbdoclet.50655241_95185" /> for information about encoding
|
|
|
|
|
this information in the symbol table entries of functions.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_ExternalProtocols" /> summarizes the
|
|
|
|
|
protocol requirements for external function calls, and
|
|
|
|
|
<xref linkend="dbdoclet.50655241_LocalProtocols" /> summarizes the
|
|
|
|
|
protocol requirements for local function calls. Each entry in these
|
|
|
|
|
tables is further described in the referenced section.
|
|
|
|
|
<note><para>Note that
|
|
|
|
|
this ABI does not define protocols where the caller does not use
|
|
|
|
|
a TOC pointer, but does preserve r2. It is most efficient when
|
|
|
|
|
such functions are always leaf procedures. It is not forbidden for
|
|
|
|
|
such a function to call another function, but in this case it is
|
|
|
|
|
up to the caller to save and restore r2 around each call.
|
|
|
|
|
</para></note>
|
|
|
|
|
</para>
|
|
|
|
|
<table frame="all" pgwide="1"
|
|
|
|
|
xml:id="dbdoclet.50655241_ExternalProtocols">
|
|
|
|
|
<title>Protocols for External Function Calls</title>
|
|
|
|
|
<tgroup cols="6">
|
|
|
|
|
<colspec colname="c1" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c2" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c3" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c4" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c5" colwidth="13*" align="center" />
|
|
|
|
|
<colspec colname="c6" colwidth="15*" align="center" />
|
|
|
|
|
<thead valign="middle">
|
|
|
|
|
<row>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Caller
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Callee
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
PLT stub
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
nop needed?
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Relocation
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Section link
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody valign="middle">
|
|
|
|
|
<row>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Uses TOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Any
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
r2 save
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Yes
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Ext2"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
<row>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Does not use TOC, does not preserve r2
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Any
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No r2 save
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24_NOTOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Ext1"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
</tbody>
|
|
|
|
|
</tgroup>
|
|
|
|
|
</table>
|
|
|
|
|
<table frame="all" pgwide="1"
|
|
|
|
|
xml:id="dbdoclet.50655241_LocalProtocols">
|
|
|
|
|
<title>Protocols for Local Function Calls</title>
|
|
|
|
|
<tgroup cols="6">
|
|
|
|
|
<colspec colname="c1" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c2" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c3" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c4" colwidth="8*" align="center" />
|
|
|
|
|
<colspec colname="c5" colwidth="13*" align="center" />
|
|
|
|
|
<colspec colname="c6" colwidth="15*" align="center" />
|
|
|
|
|
<thead valign="middle">
|
|
|
|
|
<row>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Caller
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Callee
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Call method
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
nop needed?
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Relocation
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry align="center" rowsep="1">
|
|
|
|
|
<para>
|
|
|
|
|
Section link
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody valign="middle">
|
|
|
|
|
<row>
|
|
|
|
|
<entry morerows="2">
|
|
|
|
|
<para>
|
|
|
|
|
Uses TOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Uses TOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Local
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Local20"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
<row>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Does not use TOC, preserves r2
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Local
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Local20"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
<row>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Does not use TOC, does not preserve r2
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
r2 save stub
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Yes
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Local21"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
<row>
|
|
|
|
|
<entry morerows="1">
|
|
|
|
|
<para>
|
|
|
|
|
Does not use TOC, does not preserve r2
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Uses TOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
r12 setup stub
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24_NOTOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Local12"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
<row>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Does not use TOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
Local
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
No
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
R_PPC64_REL24_NOTOC
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
<entry>
|
|
|
|
|
<para>
|
|
|
|
|
<xref linkend="dbdoclet.50655241_Local10"
|
|
|
|
|
xrefstyle="select: nopage" />
|
|
|
|
|
</para>
|
|
|
|
|
</entry>
|
|
|
|
|
</row>
|
|
|
|
|
</tbody>
|
|
|
|
|
</tgroup>
|
|
|
|
|
</table>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Ext2">
|
|
|
|
|
<title>External Call, Caller Uses TOC</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that uses a TOC pointer makes any call to an
|
|
|
|
|
external function, the compiler generates a nop instruction after the
|
|
|
|
|
bl instruction for the call. The linker generates a procedure
|
|
|
|
|
linkage table (PLT) stub that saves r2 and replaces the nop
|
|
|
|
|
instruction with a restore of r2. (The save of r2 may be omitted
|
|
|
|
|
from the PLT stub if the R_PPC64_TOCSAVE relocation is used; see
|
|
|
|
|
<xref linkend="dbdoclet.50655241_90220" />.) If the callee requires
|
|
|
|
|
a TOC, the PLT stub also includes code to place the callee's global
|
|
|
|
|
entry point into r12. See <xref linkend="dbdoclet.50655242_82622"
|
|
|
|
|
/> for a full description of PLT stubs.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Ext1">
|
|
|
|
|
<title>External Call, Caller Does Not Use TOC, Caller Does Not Preserve
|
|
|
|
|
r2</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that does not use a TOC pointer and does not preserve
|
|
|
|
|
r2 makes any call to an
|
|
|
|
|
external function, the compiler does not generate a nop instruction
|
|
|
|
|
after the bl instruction for the call. Instead, the compiler
|
|
|
|
|
annotates the bl instruction with an R_PPC64_REL24_NOTOC
|
|
|
|
|
relocation. The linker generates a PLT stub that does not include
|
|
|
|
|
a save of r2. If the callee requires a TOC, the PLT stub also
|
|
|
|
|
includes code to place the callee's global entry point into r12.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Local20">
|
|
|
|
|
<title>Local Call, Caller Uses TOC, Callee Preserves r2</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that uses a TOC pointer makes a local call to a
|
|
|
|
|
function that also preserves r2, the compiler generates a direct call
|
|
|
|
|
to the function's local entry point, and does not generate a nop
|
|
|
|
|
instruction after the call.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Local21">
|
|
|
|
|
<title>Local Call, Caller Uses TOC, Callee Does Not Preserve r2</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that uses a TOC pointer makes a local call to a
|
|
|
|
|
function
|
|
|
|
|
that does not preserve r2, the compiler generates a nop instruction
|
|
|
|
|
after the call. The linker generates a PLT stub that saves r2, but
|
|
|
|
|
does not include code to place the callee's global entry point into
|
|
|
|
|
r12, and replaces the nop instruction with a restore of r2. (The
|
|
|
|
|
save of r2 may be omitted from the PLT stub if the R_PPC64_TOCSAVE
|
|
|
|
|
relocation is used; see <xref linkend="dbdoclet.50655241_90220" />.)
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Local12">
|
|
|
|
|
<title>Local Call, Caller Does Not Preserve r2, Callee Uses TOC</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that does not use a TOC and does not preserve r2
|
|
|
|
|
makes a local call to
|
|
|
|
|
a function that requires a TOC pointer, the compiler does not
|
|
|
|
|
generate a nop instruction after the bl instruction for the call.
|
|
|
|
|
The linker generates a PLT stub that does not include a save of r2,
|
|
|
|
|
but does include code to place the callee's global entry point into
|
|
|
|
|
r12. The compiler annotates the bl instruction with an
|
|
|
|
|
R_PPC64_REL24_NOTOC relocation.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655241_Local10">
|
|
|
|
|
<title>Local Call, Caller Does Not Preserve r2, Callee Does Not Use
|
|
|
|
|
TOC</title>
|
|
|
|
|
<para>
|
|
|
|
|
When a function that does not use a TOC and does not preserve r2
|
|
|
|
|
makes a local call to
|
|
|
|
|
a function that does not require a TOC pointer, the compiler
|
|
|
|
|
generates a direct call to the function's local entry point, and
|
|
|
|
|
does not generate a nop instruction after the call. The compiler
|
|
|
|
|
annotates the bl instruction with an R_PPC64_REL24_NOTOC relocation.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
</section>
|
|
|
|
|
<section xml:id="dbdoclet.50655240___RefHeading___Toc377640579">
|
|
|
|
|
<title>Registers</title>
|
|
|
|
|
<para>Programs and compilers may freely use all registers except those
|
|
|
|
@ -4210,9 +4630,9 @@ xml:id="dbdoclet.50655240_pgfId-1156194">
|
|
|
|
|
<entry>
|
|
|
|
|
<para>Nonvolatile<footnote>
|
|
|
|
|
<para>Register r2 is nonvolatile with respect to calls
|
|
|
|
|
between functions in the same compilation unit <phrase
|
|
|
|
|
revisionflag="added">when the caller requires a TOC
|
|
|
|
|
pointer</phrase>. It is saved and restored by code inserted
|
|
|
|
|
between <phrase revisionflag="added">most</phrase> functions
|
|
|
|
|
in the same compilation unit. It is saved and restored by
|
|
|
|
|
code inserted
|
|
|
|
|
by the linker resolving a call to an external function. For
|
|
|
|
|
more information, see <xref linkend="dbdoclet.50655240_51083"
|
|
|
|
|
/> <phrase revisionflag="added"> and <xref
|
|
|
|
@ -4220,9 +4640,8 @@ xml:id="dbdoclet.50655240_pgfId-1156194">
|
|
|
|
|
</footnote><phrase revisionflag="added"> or
|
|
|
|
|
Volatile<footnote>
|
|
|
|
|
<para>Register r2 is volatile and available for use in a
|
|
|
|
|
function whose symbol table entry contains an st_other
|
|
|
|
|
field wherein the three most-significant bits have a value
|
|
|
|
|
of 001. See
|
|
|
|
|
function that does not use a TOC pointer and that does
|
|
|
|
|
not preserve r2. See
|
|
|
|
|
<xref linkend="dbdoclet.50655241_FnLinkage" />.</para>
|
|
|
|
|
</footnote></phrase></para>
|
|
|
|
|
</entry>
|
|
|
|
@ -4416,8 +4835,9 @@ xml:id="dbdoclet.50655240_pgfId-1156194">
|
|
|
|
|
appropriate TOC save and restore code. If the function is called from
|
|
|
|
|
the same module as the callee, the callee must <phrase
|
|
|
|
|
revisionflag="added">normally</phrase> preserve the value of r2.
|
|
|
|
|
<phrase revisionflag="added">However, if the callee's symbol table
|
|
|
|
|
entry is flagged to indicate the callee does not preserve r2, the
|
|
|
|
|
<phrase revisionflag="added">If the callee function is called from
|
|
|
|
|
a function in the same compilation unit as the callee, and the
|
|
|
|
|
callee does not preserve r2, the
|
|
|
|
|
caller is responsible for saving and restoring the TOC pointer if it
|
|
|
|
|
needs it.</phrase> (See <phrase revisionflag="changed"><xref
|
|
|
|
|
linkend="dbdoclet.50655241_FnLinkage" />
|
|
|
|
@ -6380,7 +6800,7 @@ plxv v1, symbol@pcrel</programlisting>
|
|
|
|
|
<itemizedlist>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para revisionflag="added">By using PC-relative GOT-indirect
|
|
|
|
|
addressing (for shared data or very large span from code to data):
|
|
|
|
|
addressing (for shared data):
|
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</itemizedlist>
|
|
|
|
@ -6418,9 +6838,7 @@ lvx v1, 0, r12</programlisting>
|
|
|
|
|
<title>Code Models</title>
|
|
|
|
|
<para>Compilers may provide different code models depending on the
|
|
|
|
|
expected size of the TOC and the size of the entire executable or
|
|
|
|
|
shared library. <phrase revisionflag="added">Assuming that the
|
|
|
|
|
TOC pointer is used to address data and/or text, the following
|
|
|
|
|
considerations apply:</phrase></para>
|
|
|
|
|
shared library.</para>
|
|
|
|
|
<itemizedlist>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>Small code model: The TOC is accessed using 16-bit offsets
|
|
|
|
@ -6464,25 +6882,11 @@ lvx v1, 0, r12</programlisting>
|
|
|
|
|
sections is provided in
|
|
|
|
|
<xref linkend="dbdoclet.50655241_66700" />.</para>
|
|
|
|
|
<para revisionflag="added">
|
|
|
|
|
PC-relative addressing may be used in either the small or the
|
|
|
|
|
medium code model, and is identical for both. Accesses to
|
|
|
|
|
PC-relative addressing may be used with the medium code model.
|
|
|
|
|
Accesses to
|
|
|
|
|
module-local code and data objects use PC-relative addressing with
|
|
|
|
|
up to 34-bit offsets. Position-independent code uses PC-relative
|
|
|
|
|
GOT-indirect addressing to access other objects in the binary.
|
|
|
|
|
If PC-relative addressing span is insufficient to reach any data
|
|
|
|
|
item, that access must either be made relative to the TOC
|
|
|
|
|
pointer, or a PC-relative indexed form instruction must be used
|
|
|
|
|
for the access. PC-relative indexed form instructions provide
|
|
|
|
|
up to 64 bits of offset from the current instruction address.
|
|
|
|
|
[To discuss: I'm deliberately leaving this flexible for now.
|
|
|
|
|
Any concerns? It appears we will probably not see a
|
|
|
|
|
load-high-immediate-32 sort of instruction in P10, so we won't
|
|
|
|
|
be able to define those kinds of relocs yet.]
|
|
|
|
|
</para>
|
|
|
|
|
<para revisionflag="added">
|
|
|
|
|
When linking objects that contain PC-relative relocations, the
|
|
|
|
|
linker should attempt to place the .got section near the text
|
|
|
|
|
sections.
|
|
|
|
|
GOT-indirect addressing to access shared objects.
|
|
|
|
|
</para>
|
|
|
|
|
</section>
|
|
|
|
|
</section>
|
|
|
|
@ -6513,11 +6917,16 @@ lvx v1, 0, r12</programlisting>
|
|
|
|
|
value. Function pointers shared between modules shall always use the
|
|
|
|
|
global entry point to specify the address of a function.</para>
|
|
|
|
|
<para>When a linker causes control to transfer to a global entry point
|
|
|
|
|
<phrase revisionflag="added">of a function that requires a TOC
|
|
|
|
|
pointer</phrase>,
|
|
|
|
|
<phrase revisionflag="added">of a function that also has a local entry
|
|
|
|
|
point</phrase>,
|
|
|
|
|
it must insert a glue code sequence that loads r12 with the global
|
|
|
|
|
entry-point address. Code at the global entry point can assume that
|
|
|
|
|
register r12 points to the GEP.</para>
|
|
|
|
|
entry-point address. Code at the global entry point <phrase
|
|
|
|
|
revisionflag="added">of a function that also has a local entry
|
|
|
|
|
point</phrase> can assume that
|
|
|
|
|
register r12 points to the GEP. <phrase revisionflag="added">
|
|
|
|
|
However, code at the global entry point of a function that does not
|
|
|
|
|
have a separate local entry point cannot make any assumptions about
|
|
|
|
|
the values of either r2 or 12.</phrase></para>
|
|
|
|
|
<para>Addresses between the global and local entry points must not be
|
|
|
|
|
branch targets, either for function entry or referenced by program
|
|
|
|
|
logic of the function, because a linker may rewrite the code sequence
|
|
|
|
@ -7479,10 +7888,6 @@ nop</programlisting>
|
|
|
|
|
<xref linkend="dbdoclet.50655242_20388" />.</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</orderedlist>
|
|
|
|
|
<para revisionflag="added">
|
|
|
|
|
For a function call in a function that does not preserve r2, the nop in
|
|
|
|
|
<xref linkend="dbdoclet.50655240_85319" /> need not be generated.
|
|
|
|
|
</para>
|
|
|
|
|
<para>For indirect function calls, the address of the function to be
|
|
|
|
|
called is placed in r12 and the CTR register. A bctrl instruction is used
|
|
|
|
|
to perform the indirect branch as shown in
|
|
|
|
@ -7717,8 +8122,9 @@ bctrl</programlisting>
|
|
|
|
|
<listitem><para>When the callee is in the same compilation unit and
|
|
|
|
|
is guaranteed to preserve r2.</para></listitem>
|
|
|
|
|
</itemizedlist>
|
|
|
|
|
In both cases, the bl instruction must be marked with an
|
|
|
|
|
R_PPC64_REL24_NOTOC relocation.
|
|
|
|
|
In the first case, the bl instruction must be marked with an
|
|
|
|
|
R_PPC64_REL24_NOTOC relocation. See <xref
|
|
|
|
|
linkend="dbdoclet.50655241_90220" />.
|
|
|
|
|
</para>
|
|
|
|
|
<para>For calls to functions resolved at runtime, the linker must
|
|
|
|
|
generate stub code to load the function address from the PLT.</para>
|
|
|
|
@ -8651,8 +9057,11 @@ addi r3,r1,p ; R3 = new data area following parameter save area.</pro
|
|
|
|
|
about how to locate this material, see
|
|
|
|
|
<xref linkend="dbdoclet.50655239___RefHeading___Toc377640569" />.</para>
|
|
|
|
|
<para revisionflag="added">
|
|
|
|
|
[Ignorant question to discuss: Are there any impacts to unwinding from
|
|
|
|
|
new r2 preservation rules?]
|
|
|
|
|
When unwinding, care must be taken to restore the TOC pointer r2 if and
|
|
|
|
|
only if it has been saved. It is recommended that the unwinder reads the
|
|
|
|
|
instruction at the return address in the link register and restores r2
|
|
|
|
|
if and only if that instruction is an explicit restore of r2, i.e.,
|
|
|
|
|
ld r2,24(r1).
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|