Files
llvm-project/llvm/lib/Object/MachOObjectFile.cpp
Francesco Petrogalli 460c9b2db1 [RISC-V][Mach-O] Add assembler support for Mach-O relocations. (#177446)
This patch adds comprehensive assembler (MC layer) support for the
Mach-O object file format on RISC-V targets, enabling assembly and
disassembly of RISC-V code targeting Apple platforms.

Key changes:

- Define RISC-V-specific Mach-O relocation types in BinaryFormat/MachO.h
- Implement RISCVMachObjectWriter with full relocation handling for:
  - PCREL_HI/LO pairs for PC-relative addressing
  - GOT relocations for external symbols
  - Branch relocations (CALL, unconditional/conditional branches)
  - Data section relocations

Test files include llvm-otool dumps to verify the generated relocations.

This code is based on code originally written by Tim Northover.
2026-01-26 14:06:30 -08:00

206 KiB