void orc_x86_do_fixups (OrcCompiler *compiler) { int i; for(i=0;i<compiler->n_fixups;i++){ if (compiler->fixups[i].type == 0) { unsigned char *label = compiler->labels[compiler->fixups[i].label]; unsigned char *ptr = compiler->fixups[i].ptr; int diff; diff = ((orc_int8)ptr[0]) + (label - ptr); if (diff != (orc_int8)diff) { ORC_COMPILER_ERROR(compiler, "short jump too long"); } ptr[0] = diff; } else if (compiler->fixups[i].type == 1) { unsigned char *label = compiler->labels[compiler->fixups[i].label]; unsigned char *ptr = compiler->fixups[i].ptr; int diff; diff = ORC_READ_UINT32_LE (ptr) + (label - ptr); ORC_WRITE_UINT32_LE(ptr, diff); } } }
void orc_mips_do_fixups (OrcCompiler *compiler) { int i; for(i=0;i<compiler->n_fixups;i++){ /* Type 0 of fixup is a branch label that could not be resolved at first * pass. We compute the offset, which should be the 16 least significant * bits of the instruction. */ unsigned char *label = compiler->labels[compiler->fixups[i].label]; unsigned char *ptr = compiler->fixups[i].ptr; orc_uint32 code; int offset; ORC_ASSERT (compiler->fixups[i].type == 0); offset = (label - (ptr + 4)) >> 2; code = ORC_READ_UINT32_LE (ptr); code |= offset & 0xffff; ORC_WRITE_UINT32_LE (ptr, code); } }
void orc_mips_emit (OrcCompiler *compiler, orc_uint32 insn) { ORC_WRITE_UINT32_LE (compiler->codeptr, insn); compiler->codeptr+=4; }