diff --git a/dynasm/dasm_ppc.lua b/dynasm/dasm_ppc.lua index 3ce29b39..ff144edb 100644 --- a/dynasm/dasm_ppc.lua +++ b/dynasm/dasm_ppc.lua @@ -257,9 +257,11 @@ map_op = { addic_3 = "30000000RRI", ["addic._3"] = "34000000RRI", addi_3 = "38000000RR0I", + addil_3 = "38000000RR0J", li_2 = "38000000RI", la_2 = "38000000RD", addis_3 = "3c000000RR0I", + addisl_3 = "3c000000RR0J", lis_2 = "3c000000RI", lus_2 = "3c000000RU", bc_3 = "40000000AAK", diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c index 0a920c1f..00bedee7 100644 --- a/src/host/buildvm_asm.c +++ b/src/host/buildvm_asm.c @@ -139,6 +139,16 @@ static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, if ((ins >> 26) == 16) { fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n", (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); +#if LJ_ARCH_PPC64 + } else if ((ins >> 26) == 14) { + if (strcmp(sym, "TOC") < 0) { + fprintf(ctx->fp, "\taddi 2,2,%s\n", sym); + } + } else if ((ins >> 26) == 15) { + if (strcmp(sym, "TOC") < 0) { + fprintf(ctx->fp, "\taddis 2,12,%s\n", sym); + } +#endif } else if ((ins >> 26) == 18) { #if LJ_ARCH_PPC64 char *suffix = strchr(sym, '@');