[all-commits] [llvm/llvm-project] 16dcf4: [RISC-V][Mach-O] Fix bogus 12-bit range check on s...

Francesco Petrogalli via All-commits all-commits at lists.llvm.org
Mon Sep 21 12:21:30 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16dcf47ee4fb8a9cb6dd8759e7be6599d935b618
      https://github.com/llvm/llvm-project/commit/16dcf47ee4fb8a9cb6dd8759e7be6599d935b618
  Author: Francesco Petrogalli <francesco.petrogalli at apple.com>
  Date:   2026-09-21 (Mon, 21 Sep 2026)

  Changed paths:
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVMachObjectWriter.cpp
    M llvm/test/MC/RISCV/riscv-relocs-macho-data.s
    M llvm/test/MC/RISCV/riscv-relocs-macho.s

  Log Message:
  -----------
  [RISC-V][Mach-O] Fix bogus 12-bit range check on subtraction expressions. (#222205)

Assembling a subtraction expression whose offset does not fit in a
signed 12-bit integer, such as

    .word _a - _b + 5000

failed with a misleading diagnostic:

    error: AUIPC out of range of corresponding %pcrel_lo instruction

The check was copied from the %pcrel_lo path, where 12 bits is a real
constraint because the offset is inlined in the immediate field of an
addi or an lw. For data, the addend is stored inline in the bytes
being relocated, and a .word has all 32 bits available to hold it.

Drop the check. No extra relocation record is needed; the
offset is simply written in the data, as otool reports in the tests:

    .long 5000 @ KIND_DATA



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list