adr_l

adrp得到一个大小为4KB的页的基址,而且在该页中有全局变量sym的地址;ADRP就是讲该页的基址存到寄存器dst中; add指令会算出sym的地址,:lo12:\\sym是一个偏移量;这样就得到了sym的地址dst。

arch/arm64/include/asm/assembler.h

 1/*
 2 * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
 3 * <symbol> is within the range +/- 4 GB of the PC.
 4 */
 5	/*
 6	 * @dst: destination register (64 bit wide)
 7	 * @sym: name of the symbol
 8	 */
 9	.macro	adr_l, dst, sym
10	adrp	\dst, \sym
11	add	\dst, \dst, :lo12:\sym
12	.endm
13
14	/*
15	 * @dst: destination register (32 or 64 bit wide)
16	 * @sym: name of the symbol
17	 * @tmp: optional 64-bit scratch register to be used if <dst> is a
18	 *       32-bit wide register, in which case it cannot be used to hold
19	 *       the address
20	 */
21	.macro	ldr_l, dst, sym, tmp=
22	.ifb	\tmp
23	adrp	\dst, \sym
24	ldr	\dst, [\dst, :lo12:\sym]
25	.else
26	adrp	\tmp, \sym
27	ldr	\dst, [\tmp, :lo12:\sym]
28	.endif
29	.endm
30
31	/*
32	 * @src: source register (32 or 64 bit wide)
33	 * @sym: name of the symbol
34	 * @tmp: mandatory 64-bit scratch register to calculate the address
35	 *       while <src> needs to be preserved.
36	 */
37	.macro	str_l, src, sym, tmp
38	adrp	\tmp, \sym
39	str	\src, [\tmp, :lo12:\sym]
40	.endm