Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm64下为什么不使用更短的绝对跳转? #19

Open
XMDS opened this issue Dec 13, 2022 · 3 comments
Open

Arm64下为什么不使用更短的绝对跳转? #19

XMDS opened this issue Dec 13, 2022 · 3 comments

Comments

@XMDS
Copy link

XMDS commented Dec 13, 2022

LDR x17, #0x8
BR x17
addr

这里使用x16 x17 x18都可,前2个状态寄存器,后1个平台寄存器。在标准的情况下,arm64下几乎不会使用它们。它们完全可以随意使用,仅手写asm的情况下才会被占用

@XMDS
Copy link
Author

XMDS commented Dec 13, 2022

ADR X10, #C
LDR X10, [X10,#0]
BR X10
addr

项目中这样占用一个会被使用寄存器,且占用20字节。

或者4G范围跳转:

ADRP x17, addr
BR x17

adrp需要考虑页对齐,但4G范围已经很大了

虽然使用x16和x18也行,但更建议使用x17,因为大部分hook项目都使用x17,兼容性会更好

@Misaka-Mikoto-Tech
Copy link
Owner

感谢提供方案,方便的话可以提个pr吗?

@adfansong
Copy link

大佬们,可不可以把arm64_far完善一下,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants