【发布时间】:2023-04-10 17:34:02
【问题描述】:
我想编码一个 64 位相对跳转到 x64 汇编中存储在 %rax 中的地址。 AFAIK,没有操作码,所以我手动计算相对地址对应的绝对地址,然后绝对跳转到绝对地址:
# destination address, relative to end of jmp instruction, is stored in %rax
00007ffff7ff6020: 0x0000488d1505000000 lea 0x5(%rip),%rdx # load %rip+5 (rip + size of add and jmpq) into %rdx
00007ffff7ff6027: 0x0000000000004801d0 add %rdx,%rax # calculate absolute address based on %rdx (behind jmpq) and %rax (the relative address)
00007ffff7ff602a: 0x00000000000000ffe0 jmpq *%rax # do an absolute jump to absolute address
但这在我看来是不必要的复杂。有没有更少指令的更好方法?还是应该避免 64 位相对跳转的其他原因?
【问题讨论】:
标签: assembly 64-bit x86-64 att