title date categories tags
Relocation
2024-09-16 19:00:20 +0800
Elf
elf
         assemble          link
assembly -------> object --------> executable

Assemble Process

Link Process

RISC-V Relocation

32-bit Absolute Address

lui R_RISCV_HI20 S + A
addi/ld R_RISCV_LO12_I S + A
sd R_RISCV_LO12_S S + A

32-bit PC-Relative Address

auipc R_RISCV_PCREL_HI20 S + A - P
addi/ld R_RISCV_PCREL_LO12_I S - P
sd R_RISCV_PCREL_LO12_S S - P

Procedure Calls

auipc R_RISCV_CALL_PLT S + A - P
jalr N/A N/A

PC-Relative Jumps and Branches

RISC-V Relaxation