IPR-NIOS Altera, IPR-NIOS Datasheet - Page 182

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
7–18
Nios II Processor Reference Handbook
Linux Program Loading and Dynamic Linking
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
Multi-way branches such as switch statements can be implemented with a table of
GOT-relative offsets, as shown in
Example 7–17. Switch Statement Implemented with Table
# Scaled table offset in r4
Ltable:
Global Offset Table
Because shared libraries are position-independent, they can not contain absolute
addresses for symbols. Instead, addresses are loaded from the GOT.
The first word of the GOT is filled in by the link editor with the unrelocated address of
the _DYNAMIC, which is at the start of the dynamic section. The second and third words
are reserved for the dynamic linker. For information about the dynamic linker, refer to
“Procedure Linkage Table” on page
The linker-defined symbol _GLOBAL_OFFSET_TABLE_ points to the reserved entries at
the beginning of the GOT. The linker-defined symbol _gp_got points to the base
address used for GOT-relative relocations. The value of _gp_got might vary between
object files if the linker creates multiple GOT sections.
Function Addresses
Function addresses use the same SHN_UNDEF and st_value convention for PLT entries
as in other architectures, such as x86_64.
orhi
addi
add
add
ldw
add
jmp
...
.word
.word
.word
r3, %gotoff_hiadj(x)
r3, r3, %gotoff_lo(x)
r3, r22, r3
r3, %gotoff_hiadj(Ltable)
r3, r3, %gotoff_lo(Ltable) # R_NIOS2_GOTOFF_LO Ltable
r3, r22, r3
r3, r3, r4
r4, 0(r3)
r4, r4, r22
r4
%gotoff(Label1)
%gotoff(Label2)
%gotoff(Label3)
Example
7–19.
# R_NIOS2_GOTOFF_HA x
# R_NIOS2_GOTOFF_LO x
# R_NIOS2_GOTOFF_HA Ltable
# r3 == &Ltable
# r3 == Ltable[index]
# Convert offset into destination
7–17.
Chapter 7: Application Binary Interface
December 2010 Altera Corporation
Example
ABI for Linux Systems
7–16.

Related parts for IPR-NIOS