Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
elf.h File Reference

OpenRISC (or1k) ELF relocation type definitions and helpers for LLEXT. More...

Go to the source code of this file.

Macros

#define R_OR1K_INSN_REL_26_MASK   0x03ffffffU
 OpenRISC relocation types.
#define R_OR1K_IMM16_MASK   0x0000ffffU
 Mask for the 16-bit immediate field (bits [15:0]) - used by l.ori, l.addi, l.movhi, etc.
#define R_OR1K_PG21_MASK   0x001fffffU
 Mask for the 21-bit page-relative field (bits [20:0]) - used by l.adrp.
#define R_OR1K_SLO_FIELD_MASK   0x03e007ffU
 Split-immediate mask for OR1K store instructions.
#define R_OR1K_SLO_PACK(insn, imm)
 Pack a 16-bit immediate into the OR1K split-immediate store format.
#define R_OR1K_PAGE_SIZE   8192U
 OR1K page size for PCREL_PG21 relocations (8 KB = 2^13).
#define R_OR1K_PAGE_MASK   (~(R_OR1K_PAGE_SIZE - 1U))
 OR1K page mask for PCREL_PG21 relocations (8 KB aligned).

Detailed Description

OpenRISC (or1k) ELF relocation type definitions and helpers for LLEXT.

Macro Definition Documentation

◆ R_OR1K_IMM16_MASK

#define R_OR1K_IMM16_MASK   0x0000ffffU

Mask for the 16-bit immediate field (bits [15:0]) - used by l.ori, l.addi, l.movhi, etc.

◆ R_OR1K_INSN_REL_26_MASK

#define R_OR1K_INSN_REL_26_MASK   0x03ffffffU

OpenRISC relocation types.

From the official OR1K ELF specification and binutils.

OR1K instruction field masks

OR1K instructions are fixed 32-bit, big-endian. Immediate fields are located in the low bits of the instruction word. Mask for the 26-bit jump/branch target field (bits [25:0])

◆ R_OR1K_PAGE_MASK

#define R_OR1K_PAGE_MASK   (~(R_OR1K_PAGE_SIZE - 1U))

OR1K page mask for PCREL_PG21 relocations (8 KB aligned).

◆ R_OR1K_PAGE_SIZE

#define R_OR1K_PAGE_SIZE   8192U

OR1K page size for PCREL_PG21 relocations (8 KB = 2^13).

◆ R_OR1K_PG21_MASK

#define R_OR1K_PG21_MASK   0x001fffffU

Mask for the 21-bit page-relative field (bits [20:0]) - used by l.adrp.

◆ R_OR1K_SLO_FIELD_MASK

#define R_OR1K_SLO_FIELD_MASK   0x03e007ffU

Split-immediate mask for OR1K store instructions.

Store instructions (l.sw, l.sb, l.sh) encode a 16-bit signed immediate split across two non-contiguous fields:

  • Bits [15:11] of the immediate → instruction bits [25:21]
  • Bits [10:0] of the immediate → instruction bits [10:0]

The combined field mask is 0x03E007FF.

◆ R_OR1K_SLO_PACK

#define R_OR1K_SLO_PACK ( insn,
imm )
Value:
(((insn) & ~R_OR1K_SLO_FIELD_MASK) | \
(((uint32_t)(imm) & 0xf800U) << 10) | \
((uint32_t)(imm) & 0x07ffU))
#define R_OR1K_SLO_FIELD_MASK
Split-immediate mask for OR1K store instructions.
Definition elf.h:117
__UINT32_TYPE__ uint32_t
Definition stdint.h:90

Pack a 16-bit immediate into the OR1K split-immediate store format.

Parameters
insnThe existing 32-bit instruction word
immThe 16-bit immediate value to pack
Returns
The instruction word with the immediate inserted