IPR-NIOS Altera, IPR-NIOS Datasheet - Page 181

no-image

IPR-NIOS

Manufacturer Part Number
IPR-NIOS
Description
IP NIOS II MEGACORE RENEW
Manufacturer
Altera
Type
MegaCorer
Datasheet

Specifications of IPR-NIOS

License
Renewal License
Lead Free Status / RoHS Status
Not applicable / Not applicable
Chapter 7: Application Binary Interface
ABI for Linux Systems
December 2010 Altera Corporation
Linux Position-Independent Code
Every position-independent code (PIC) function which uses global data or global
functions must load the value of the GOT pointer into a register. Any available
register may be used. If a caller-saved register is used the function must save and
restore it around calls. If a callee-saved register is used it must be saved and restored
around the current function. Examples in this document use r22 for the GOT pointer.
The GOT pointer is loaded using a PC-relative offset to the _gp_got symbol, as shown
in
Example 7–12. Loading the GOT Pointer
nextpc r22
1:
Data may be accessed by loading its location from the GOT. A single word GOT entry
is generated for each referenced symbol. For global symbols, the entry is as shown in
Example
Example 7–13. GOT Entry for Global Symbols
addi
GOT[n]
For local symbols, the symbolic reference to x is replaced by a relative relocation
against symbol zero, with the link time address of x as an addend, as shown in
Example
Example 7–14. Local Symbols
addi
GOT[n]
The call and jmpi instructions are not available in position-independent code.
Instead, all calls are made through the GOT. Function addresses may be loaded with
%call, which allows lazy binding. To initialize a function pointer, load the address of
the function with %got instead. If no input object requires the address of the function
its GOT entry is placed in the PLT GOT for lazy binding, as shown in
For information about the PLT, refer to
Example 7–15. GOT entry in PLT GOT
ldw
callr
PLTGOT[n]
orhi
addi
add
# GOT pointer in r22
Example
r3, r22, %got(x)
r3, r22, %got(x)
r3, %call(fun)(r22)
r3
7–13.
7–14.
r1, %hiadj(_gp_got - 1b)
r1, r1, %lo(_gp_got - 1b)
r22, r22, r1
7–12.
“Procedure Linkage Table” on page
# R_NIOS2_GOT16
# R_NIOS2_GOT16
# R_NIOS2_CALL16 fun
# R_NIOS2_PCREL_HA _gp_got
# R_NIOS2_PCREL_LO _gp_got - 4
R_NIOS2_GLOB_DAT x
R_NIOS2_RELATIVE +x
R_NIOS_JUMP_SLOT fun
Nios II Processor Reference Handbook
Example
7–19.
7–15.
7–17

Related parts for IPR-NIOS