[llvm] [RISC-V][Mach-O] Add assembler support for Mach-O relocations. (PR #177446)
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 29 09:04:50 PST 2026
================
@@ -477,6 +477,56 @@ enum RelocationInfoType {
// An authenticated pointer.
ARM64_RELOC_AUTHENTICATED_POINTER = 11,
+ // For pointers. For example, for a .word directive in assembly
+ // representing a memory location where data is stored:
+ // .word: _bar
+ RISCV_RELOC_UNSIGNED = 0,
+ // Subtractor operand. Must be followed by a RISCV_RELOC_UNSIGNED,
+ // which is the pointer from which to subtract the subtractor. For
+ // example:
+ //
+ // .global _a
+ // .global _b
+ // _a: ...
+ // _b: ...
+ //
+ // .data_region
+ // .word _a - _b
+ // .end_data_region
+ RISCV_RELOC_SUBTRACTOR = 1,
+ // A B/BL instruction with 21-bit displacement. For example, a
+ // function call:
+ //
+ // _foo:
+ // call _bar
+ RISCV_RELOC_BRANCH21 = 2,
+ // High 20 bits of pointer. r_pcrel=1 means this is paired with an
+ // AUIPC. r_pcrel=0 means this is paired with a LUI.
+ RISCV_RELOC_HI20 = 3,
+ // An ADDI or LW/SW instruction that requires low 12 bits to be
+ // adjusted. r_pcrel=1 means this is paired with an AUIPC.
+ // r_pcrel=0 means this is paired with a LUI (llvm currently does
+ // not support no-PIC). Note: the compiler places the distance to
+ // the paired AUIPC in the imm12 (e.g. if previous instruction is
+ // the AUIPC, the imm12 is -4 or 0xFFC).
+ RISCV_RELOC_LO12 = 4,
----------------
fpetrogalli wrote:
@lenary - I have addressed this in https://github.com/llvm/llvm-project/pull/178699
https://github.com/llvm/llvm-project/pull/177446
More information about the llvm-commits
mailing list