Next: , Previous: , Up: NiosII-Dependent   [Contents][Index]

9.31.3 Nios II Machine Relocations


Extract the upper 16 bits of expression and add one if the 15th bit is set.

The value of %hiadj(expression) is:

((expression >> 16) & 0xffff) + ((expression >> 15) & 0x01)

The %hiadj relocation is intended to be used with the addi, ld or st instructions along with a %lo, in order to load a 32-bit constant.

movhi r2, %hiadj(symbol)
addi r2, r2, %lo(symbol)

Extract the upper 16 bits of expression.


Extract the lower 16 bits of expression.


Subtract the value of the symbol _gp from expression.

The intention of the %gprel relocation is to have a fast small area of memory which only takes a 16-bit immediate to access.

      .section .sdata
        .int 123
        .section .text
        ldw r4, %gprel(fastint)(gp)

These relocations support the ABI for Linux Systems documented in the Nios II Processor Reference Handbook.