Nios® II Processor Reference Guide

ID 683836
Date 8/28/2023
Document Table of Contents
Give Feedback

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 83.  Dynamic Relocations

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 84.  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_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_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.