Visible to Intel only — GUID: iga1409352505303
Ixiasoft
3.4.2.1. The status Register
3.4.2.2. The estatus Register
3.4.2.3. The bstatus Register
3.4.2.4. The ienable Register
3.4.2.5. The ipending Register
3.4.2.6. The cpuid Register
3.4.2.7. The exception Register
3.4.2.8. The pteaddr Register
3.4.2.9. The tlbacc Register
3.4.2.10. The tlbmisc Register
3.4.2.11. The badaddr Register
3.4.2.12. The config Register
3.4.2.13. The mpubase Register
3.4.2.14. The mpuacc Register
3.7.1. Terminology
3.7.2. Exception Overview
3.7.3. Exception Latency
3.7.4. Reset Exceptions
3.7.5. Break Exceptions
3.7.6. Interrupt Exceptions
3.7.7. Instruction-Related Exceptions
3.7.8. Other Exceptions
3.7.9. Exception Processing Flow
3.7.10. Handling Nested Exceptions
3.7.11. Handling Nonmaskable Interrupts
3.7.12. Masking and Disabling Exceptions
3.7.7.1. Trap Instruction
3.7.7.2. Break Instruction
3.7.7.3. Unimplemented Instruction
3.7.7.4. Illegal Instruction
3.7.7.5. Supervisor-Only Instruction
3.7.7.6. Supervisor-Only Instruction Address
3.7.7.7. Supervisor-Only Data Address
3.7.7.8. Misaligned Data Address
3.7.7.9. Misaligned Destination Address
3.7.7.10. Division Error
3.7.7.11. Fast TLB Miss
3.7.7.12. Double TLB Miss
3.7.7.13. TLB Permission Violation
3.7.7.14. MPU Region Violation
3.9.1. Data Transfer Instructions
3.9.2. Arithmetic and Logical Instructions
3.9.3. Move Instructions
3.9.4. Comparison Instructions
3.9.5. Shift and Rotate Instructions
3.9.6. Program Control Instructions
3.9.7. Other Control Instructions
3.9.8. Custom Instructions
3.9.9. No-Operation Instruction
3.9.10. Potential Unimplemented Instructions
8.5.1. add
8.5.2. addi
8.5.3. and
8.5.4. andhi
8.5.5. andi
8.5.6. beq
8.5.7. bge
8.5.8. bgeu
8.5.9. bgt
8.5.10. bgtu
8.5.11. ble
8.5.12. bleu
8.5.13. blt
8.5.14. bltu
8.5.15. bne
8.5.16. br
8.5.17. break
8.5.18. bret
8.5.19. call
8.5.20. callr
8.5.21. cmpeq
8.5.22. cmpeqi
8.5.23. cmpge
8.5.24. cmpgei
8.5.25. cmpgeu
8.5.26. cmpgeui
8.5.27. cmpgt
8.5.28. cmpgti
8.5.29. cmpgtu
8.5.30. cmpgtui
8.5.31. cmple
8.5.32. cmplei
8.5.33. cmpleu
8.5.34. cmpleui
8.5.35. cmplt
8.5.36. cmplti
8.5.37. cmpltu
8.5.38. cmpltui
8.5.39. cmpne
8.5.40. cmpnei
8.5.41. custom
8.5.42. div
8.5.43. divu
8.5.44. eret
8.5.45. flushd
8.5.46. flushda
8.5.47. flushi
8.5.48. flushp
8.5.49. initd
8.5.50. initda
8.5.51. initi
8.5.52. jmp
8.5.53. jmpi
8.5.54. ldb / ldbio
8.5.55. ldbu / ldbuio
8.5.56. ldh / ldhio
8.5.57. ldhu / ldhuio
8.5.58. ldw / ldwio
8.5.59. mov
8.5.60. movhi
8.5.61. movi
8.5.62. movia
8.5.63. movui
8.5.64. mul
8.5.65. muli
8.5.66. mulxss
8.5.67. mulxsu
8.5.68. mulxuu
8.5.69. nextpc
8.5.70. nop
8.5.71. nor
8.5.72. or
8.5.73. orhi
8.5.74. ori
8.5.75. rdctl
8.5.76. rdprs
8.5.77. ret
8.5.78. rol
8.5.79. roli
8.5.80. ror
8.5.81. sll
8.5.82. slli
8.5.83. sra
8.5.84. srai
8.5.85. srl
8.5.86. srli
8.5.87. stb / stbio l
8.5.88. sth / sthio
8.5.89. stw / stwio
8.5.90. sub
8.5.91. subi
8.5.92. sync
8.5.93. trap
8.5.94. wrctl
8.5.95. wrprs
8.5.96. xor
8.5.97. xorhi
8.5.98. xori
Visible to Intel only — GUID: iga1409352505303
Ixiasoft
7.8. Relocation
In a Nios II object file, each relocatable address reference possesses a relocation type. The relocation type specifies how to calculate the relocated address. The bit mask specifies where the address is found in the instruction.
Name | Value | Overflow check 44 |
Relocated Address R |
Bit Mask M |
Bit Shift B |
---|---|---|---|---|---|
R_NIOS2_NONE | 0 | n/a | None | n/a | n/a |
R_NIOS2_S16 | 1 | Yes | S + A | 0x003FFFC0 | 6 |
R_NIOS2_U16 | 2 | Yes | S + A | 0x003FFFC0 | 6 |
R_NIOS2_PCREL16 | 3 | Yes | ((S + A) – 4) – PC | 0x003FFFC0 | 6 |
R_NIOS2_CALL2645 | 4 | Yes | (S + A) >> 2 | 0xFFFFFFC0 | 6 |
R_NIOS2_CALL26_NOAT | 41 | No | (S + A) >> 2 | 0xFFFFFFC0 | 6 |
R_NIOS2_IMM5 | 5 | Yes | (S + A) & 0x1F | 0x000007C0 | 6 |
R_NIOS2_CACHE_OPX | 6 | Yes | (S + A) & 0x1F | 0x07C00000 | 22 |
R_NIOS2_IMM6 | 7 | Yes | (S + A) & 0x3F | 0x00000FC0 | 6 |
R_NIOS2_IMM8 | 8 | Yes | (S + A) & 0xFF | 0x00003FC0 | 6 |
R_NIOS2_HI16 | 9 | No | ((S + A) >> 16) & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_LO16 | 10 | No | (S + A) & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_HIADJ16 | 11 | No | Adj(S+A) | 0x003FFFC0 | 6 |
R_NIOS2_BFD_RELOC_32 | 12 | No | S + A | 0xFFFFFFFF | 0 |
R_NIOS2_BFD_RELOC_16 | 13 | Yes | (S + A) & 0xFFFF | 0x0000FFFF | 0 |
R_NIOS2_BFD_RELOC_8 | 14 | Yes | (S + A) & 0xFF | 0x000000FF | 0 |
R_NIOS2_GPREL | 15 | No | (S + A – GP) & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_GNU_VTINHERIT | 16 | n/a | None | n/a | n/a |
R_NIOS2_GNU_VTENTRY | 17 | n/a | None | n/a | n/a |
R_NIOS2_UJMP | 18 | No | ((S + A) >> 16) & 0xFFFF, (S + A + 4) & 0xFFFF |
0x003FFFC0 | 6 |
R_NIOS2_CJMP | 19 | No | ((S + A) >> 16) & 0xFFFF, (S + A + 4) & 0xFFFF |
0x003FFFC0 | 6 |
R_NIOS2_CALLR | 20 | No | ((S + A) >> 16) & 0xFFFF) (S + A + 4) & 0xFFFF |
0x003FFFC0 | 6 |
R_NIOS2_ALIGN | 21 | n/a | None | n/a | n/a |
R_NIOS2_GOT16 | 2246 | Yes | G | 0x003FFFC0 | 6 |
R_NIOS2_CALL16 | 2346 | Yes | G | 0x003FFFC0 | 6 |
R_NIOS2_GOTOFF_LO | 2446 | No | (S + A – GOT) & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_GOTOFF_HA | 2546 | No | Adj (S + A – GOT) | 0x003FFFC0 | 6 |
R_NIOS2_PCREL_LO | 2646 | No | (S + A – PC) & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_PCREL_HA | 2746 | No | Adj (S + A – PC) | 0x003FFFC0 | 6 |
R_NIOS2_TLS_GD16 | 2846 | Yes | Refer to Thread-Local Storage section | 0x003FFFC0 | 6 |
R_NIOS2_TLS_LDM16 | 2946 | Yes | Refer to Thread-Local Storage section | 0x003FFFC0 | 6 |
R_NIOS2_TLS_LDO16 | 3046 | Yes | Refer to Thread-Local Storage section | 0x003FFFC0 | 6 |
R_NIOS2_TLS_IE16 | 3146 | Yes | Refer to Thread-Local Storage section | 0x003FFFC0 | 6 |
R_NIOS2_TLS_LE16 | 3246 | Yes | Refer to Thread-Local Storage section | 0x003FFFC0 | 6 |
R_NIOS2_TLS_DTPMOD | 3346 | No | Refer to Thread-Local Storage section | 0xFFFFFFFF | 0 |
R_NIOS2_TLS_DTPREL | 3446 | No | Refer to Thread-Local Storage section | 0xFFFFFFFF | 0 |
R_NIOS2_TLS_TPREL | 3546 | No | Refer to Thread-Local Storage section | 0xFFFFFFFF | 0 |
R_NIOS2_COPY | 3646 | No | Refer to Copy Relocation section. | n/a | n/a |
R_NIOS2_GLOB_DAT | 3746 | No | S | 0xFFFFFFFF | 0 |
R_NIOS2_JUMP_SLOT | 3846 | No | Refer to Jump Slot Relocation section. | 0xFFFFFFFF | 0 |
R_NIOS2_RELATIVE | 3946 | No | BA+A | 0xFFFFFFFF | 0 |
R_NIOS2_GOTOFF | 4046 | No | S+A | 0xFFFFFFFF | 0 |
R_NIOS2_GOT_LO | 4246 | No | G & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_GOT_HA | 4346 | No | Adj(G) | 0x003FFFC0 | 6 |
R_NIOS2_CALL_LO | 4446 | No | G & 0xFFFF | 0x003FFFC0 | 6 |
R_NIOS2_CALL_HA | 4546 | No | Adj(G) | 0x003FFFC0 | 6 |
Expressions in the table above use the following conventions:
- S: Symbol address
- A: Addend
- PC: Program counter
- GP: Global pointer
- Adj(X): (((X >> 16) & 0xFFFF) + ((X >> 15) & 0x1)) & 0xFFFF
- BA: The base address at which a shared library is loaded
- GOT: The value of the Global Offset Table (GOT) pointer (Linux only)
- G: The offset into the GOT for the GOT slot for symbol S (Linux only)
With the information in the table above, any Nios II instruction can be relocated by manipulating it as an unsigned 32-bit integer, as follows:
Xr = (( R << B ) & M | ( X & ~M ));
where:
- R is the relocated address, calculated in the above table
- B is the bit shift
- M is the bit mask
- X is the original instruction
- Xr is the relocated instruction
44 For relocation types where no overflow check is performed, the relocated address is truncated to fit the instruction.
45 Linker is permitted to clobber register AT in the course of resolving overflows
46 Relocation support is provided for Linux systems.