[PATCH] [Mips] Add support for MCJIT for MIPS32r6

Simon Atanasyan simon at atanasyan.com
Wed Jun 24 06:30:36 PDT 2015

@dsanders You are absolutely right. Here is a quote from MIPS ABI:

  The AHL addend is a composite computed from the addends of two consecutive relocation
  entries. Each relocation type of R_MIPS_HI16 must have an associated
  R_MIPS_LO16 entry immediately following it in the list of relocations.
  These relocation entries are always processed as a pair and both addend fields
  contribute to the AHL addend. If AHI and ALO are the addends from the
  paired R_MIPS_HI16 and R_MIPS_LO16 entries, then the addend AHL is computed
  as (AHI << 16) + (short)ALO. R_MIPS_LO16 entries without an
  R_MIPS_HI16 entry immediately preceding are orphaned and the previously defined
  R_MIPS_HI16 is used for computing the addend.

But if addends are recorded in the SHT_RELA section we can use them as is and do not
have to calculate a combined AHL addend.

Also please note that in case of O32 ABI if R_MIPS_HI16 / R_MIPS_LO16 relocations
reference the `_gp_disp` symbol they should be calculated using special formulas:

  R_MIPS_HI16: (AHL + GP – P) – (short) (AHL + GP – P)) >> 16
  R_MIPS_LO16: AHL + GP – P + 4




More information about the llvm-commits mailing list