Nios II Classic Processor Reference Guide

ID 683620
Date 10/28/2016
Public
Document Table of Contents

7.9.1. Linux Toolchain Relocation Information

Dynamic relocations can appear in the runtime relocation sections of executables and shared objects, but never appear in object files (with the exception of R_NIOS2_TLS_DTPREL, which is used for debug information). No other relocations are dynamic.
Table 92.  Dynamic Relocations
R_NIOS2_TLS_DTPMOD
R_NIOS2_TLS_DTPREL
R_NIOS2_TLS_TPREL
R_NIOS2_COPY
R_NIOS2_GLOB_DAT
R_NIOS2_JUMP_SLOT
R_NIOS2_RELATIVE

A global offset table (GOT) entry referenced using R_NIOS2_GOT16, R_NIOS2_GOT_LO as well as R_NIOS2_GOT_HA must be resolved at load time. A GOT entry referenced only using R_NIOS2_CALL16, R_NIOS2_CALL_LO as well as R_NIOS2_CALL_HA can initially refer to a procedure linkage table (PLT) entry and then be resolved lazily.

Because the TP-relative relocations are 16-bit relocations, no dynamic object using local dynamic or local executable thread-local storage (TLS) can have more than 64 KB of TLS data. New relocations might be added to support this in the future.

Several new assembler operators are defined to generate the Linux-specific relocations, as listed in the table below.

Table 93.  Relocation and Operator
Relocation Operator
R_NIOS2_GOT16 %got
R_NIOS2_CALL16 %call
R_NIOS2_GOTOFF_LO %gotoff_hiadj
R_NIOS2_GOTOFF_HA %gotoff_lo
R_NIOS2_PCREL_LO %hiadj
R_NIOS2_PCREL_HA %lo
R_NIOS2_TLS_GD16 %tls_gd
R_NIOS2_TLS_LDM16 %tls_ldm
R_NIOS2_TLS_LDO16 %tls_ldo
R_NIOS2_TLS_IE16 %tls_ie
R_NIOS2_TLS_LE16 %tls_le
R_NIOS2_TLS_DTPREL %tls_ldo
R_NIOS2_GOTOFF %gotoff
R_NIOS2_GOT_LO %got_lo
R_NIOS2_GOT_HA %got_hiadj
R_NIOS2_CALL_LO %call_lo
R_NIOS2_CALL_HA %call_hiadj

The %hiadj and %lo operators generate PC-relative or non-PC-relative relocations, depending whether the expression being relocated is PC-relative. For instance, %hiadj(_gp_got - .) generates R_NIOS2_PCREL_HA. %tls_ldo generates R_NIOS2_TLS_LDO16 when used as an immediate operand, and R_NIOS2_TLS_DTPREL when used with the .word directive.