Altera Nios II User Manual page 174

Hide thumbs Also See for Nios II:
Table of Contents

Advertisement

7–16
The GOT pointer is loaded using a PC-relative offset to the _gp_got symbol, as shown
in
Example
Example 7–12. Loading the GOT Pointer
nextpc r22
1:
orhi
addi
add
# GOT pointer in r22
Data may be accessed by loading its location from the GOT. A single word GOT entry
is generated for each referenced symbol.
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]
When a function or variable resides in the current shared object at compile time, it can
be accessed via a PC-relative or GOT-relative offset, as shown in
Example 7–16. Accessing Function or Variable in Current Shared Object
orhi
addi
add
# Address of x in r3
Nios II Processor Reference Handbook
7–12.
r1, %hiadj(_gp_got - 1b)
r1, r1, %lo(_gp_got - 1b)
r22, r22, r1
r3, r22, %got(x)
7–14.
r3, r22, %got(x)
r3, %call(fun)(r22)
r3
r3, %gotoff_hiadj(x)
r3, r3, %gotoff_lo(x)
r3, r22, r3
Chapter 7: Application Binary Interface
# R_NIOS2_PCREL_HA _gp_got
# R_NIOS2_PCREL_LO _gp_got - 4
# R_NIOS2_GOT16
R_NIOS2_GLOB_DAT x
# R_NIOS2_GOT16
R_NIOS2_RELATIVE +x
"Procedure Linkage Table" on page
# R_NIOS2_CALL16 fun
R_NIOS_JUMP_SLOT fun
# R_NIOS2_GOTOFF_HA x
# R_NIOS2_GOTOFF_LO x
February 2014 Altera Corporation
ABI for Linux Systems
Example
7–15.
7–17.
Example
7–16.

Advertisement

Table of Contents
loading

Table of Contents