You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code throws the exception IP relative memory operand is too far away and isn't currently supported. Try to allocate memory close to the original instruction (+/-2GB). This happens because, due to the previous declared label, the address of the instruction gets overridden and the RIP relative address is then wrong.
Example:
var c = new Assembler(64);
const ulong decodeIP = 0x1E520ED0025;
var codeReader = new ByteArrayCodeReader("F2 0F 11 05 D8 FF FF FF"); // movsd [7FFD2E570000],xmm0
var decoder = Decoder.Create(64, codeReader);
decoder.IP = decodeIP;
decoder.Decode(out var instr);
var w = new StreamCodeWriter(new MemoryStream());
c.cmp(rax,1);
c.jne(c.@F);
c.ret();
c.AnonymousLabel();
c.AddInstruction(instr); // movsd [7FFD2E570000],xmm0 => but after added it becomes => movsd [0FFFFFFFFFFFFFFE1],xmm0
c.ret();
c.Assemble(w, (ulong)decodeIP, BlockEncoderOptions.ReturnNewInstructionOffsets); // <--- throws
FYI: Occurs on anonymous and non anonymous label. If the label points to another instruction no exception is thrown.
The text was updated successfully, but these errors were encountered:
Symbai
changed the title
Assembler - Fails to assemble IP relative instruction when an anonymous label was declared
Assembler - Fails to assemble IP relative instruction when a label was declared
Aug 31, 2020
The following code throws the exception
IP relative memory operand is too far away and isn't currently supported. Try to allocate memory close to the original instruction (+/-2GB).
This happens because, due to the previous declared label, the address of the instruction gets overridden and the RIP relative address is then wrong.Example:
FYI: Occurs on anonymous and non anonymous label. If the label points to another instruction no exception is thrown.
Works:
Fails:
The text was updated successfully, but these errors were encountered: