Branches
B
PC relative branch ±128 MB
Conditional version B.cond (covered later) has ±1 MB range
BL
Similar to B (branch range ±128 MB) but also stores return address in LR (X30), hinting that this is a function call
No conditional version
为什么要将范围限制在±128M?
AArch64 bl跳转大于128MB会出现什么问题?
为什么要把范围限制在±128M?
A64 指令都是 32 位宽。指定 6 位用于将
B
和 BL
与其他指令区分开来。其余 26 位对(带符号的)跳转偏移量进行编码。由于所有指令都是 4 字节宽,因此跳转只需要转到 4 字节对齐的地址,这样偏移量就可以移动 << 2, which yields a range of -0x8000000
到 0x7fffffc
,即 ±128MiB。
AArch64 bl跳转大于128MB会出现什么问题?
那么指令中没有足够的位来编码偏移量。您必须执行类似
adrp
+add
+b(l)r
之类的操作,或者如果 ADRP 的 ±4GiB 偏移量还不够,您可能只需将目标的文字地址存储在数据中的某个位置部分(动态链接器重新设置基址)并使用 ldr
+b(l)r
。