我想編碼64位相對跳轉到x64程序集中存儲在%rax中的地址。據我所知,有對此沒有操作碼,所以我手動計算相應的絕對地址的相對地址,然後我做的是絕對跳轉到絕對地址:x64:如何做一個相對jmp *%rax?
# 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位相對跳轉的另一個原因?