Page MenuHomePhabricator

[X86][MC] Fix assembling rip-relative addressing + immediate displacements

Authored by thegameg on Feb 7 2018, 4:11 PM.



In the rare case where the input contains rip-relative addressing with immediate displacements, *and* the instruction ends with an immediate, we encode the instruction in the wrong way:

movl $12345678, 0x400(%rdi) // all good, no rip-relative addr
movl %eax, 0x400(%rip) // all good, no immediate at the end of the instruction
movl $12345678, 0x400(%rip) // fails, encodes address as 0x3fc(%rip)
  • Offset is a label:
movl $12345678, foo(%rip)

we want to account for the size of the immediate (in this case, $12345678, 4 bytes) in the relocation value.

  • Offset is an immediate:
movl $12345678, 0x400(%rip)

we should not account for the size of the immediate, assuming the immediate offset is what the user wanted.

Diff Detail


Event Timeline

thegameg created this revision.Feb 7 2018, 4:11 PM
This revision is now accepted and ready to land.Feb 9 2018, 1:24 PM
This revision was automatically updated to reflect the committed changes.