I'm on the OSX platform working with x86_64. I've worked out how to do near jumps with the E9 byte code directive where my relative addresses have 4 bytes (teamed up with RIP)
Now I have an instance where I've allocated something at a very high address and where I'm going to be referencing it is very far away in the same process. the end result is that the difference between the RIP and the starting address results in 5 bytes. (if I use relative addressing). I was attempting to use FF 25 + 4 bytes + 1 byte and the fifth wasn't being interpreted as part of the command.
Indeed when I looked up the data in the table x86 architecture mod R/M byte it noted FF 25 (apparently does a RIP+signed dword). This would explain why 1 byte was being dropped. I tried examining the table and do not really understand it.
So the questions I have are
- How do I read the table so as to understand how to get the byte code to set up so I can do question #3 correctly?
- Does JMP /5 use a direct address or indirect addressing (do I have to involve the RIP as a part of the calculation)?
- What set of byte codes do I need to assemble to get a JMP /5 to take effect (eg: FF ... )
typical 4 byte jump (e9) code might look like this: (lldb session)
-> 0x100000ebb: 81 7d fc 03 00 00 00 cmpl $0x3, -0x4(%rbp) 0x100000ec2: 0f 85 05 00 00 00 jne 0x100000ecd 0x100000ec8: e9 3b 57 34 12 jmp 0x112346608 0x100000ecd: 48 8d 3d bc 00 00 00 leaq 0xbc(%rip), %rdi