On 11/27/18 1:10 PM, Alistair Francis wrote:
> +        if (short_jmp) {
> +            reloc_sbimm12(code_ptr, (tcg_insn_unit *)value);
> +        } else {
> +            /* Invert the condition */
> +            insn = insn ^ (1 << 12);
> +            /* Clear the offset */
> +            insn &= 0xFFF;
> +            /* Set the offset to the PC + 8 */
> +            insn |= ((unsigned int)(code_ptr + 8)) << 12;

This isn't a pc-relative value you're storing.

    reloc_sbimm12(code_ptr, code_ptr + 2);

> +            /* Overwrite the NOP with jal x0,value */
> +            insn = encode_uj(OPC_JAL, TCG_REG_ZERO, value);

This isn't pc-relative either.  Perhaps best as

    code_ptr[1] = encode_uj(OPC_JAL, TCG_REG_ZERO, 0);
    reloc_jimm20(code_ptr + 1, (tcg_insn_unit *)value);


r~



Reply via email to