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


9.30.3 Nios II Machine Relocations

%hiadj(expression)

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)
%hi(expression)

Extract the upper 16 bits of expression.

%lo(expression)

Extract the lower 16 bits of expression.

%gprel(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
fastint:
	.int 123
	.section .text
	ldw r4, %gprel(fastint)(gp)
%call(expression)
%call_lo(expression)
%call_hiadj(expression)
%got(expression)
%got_lo(expression)
%got_hiadj(expression)
%gotoff(expression)
%gotoff_lo(expression)
%gotoff_hiadj(expression)
%tls_gd(expression)
%tls_ie(expression)
%tls_le(expression)
%tls_ldm(expression)
%tls_ldo(expression)

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