as: AArch64-Relocations
1
1 9.1.3.3 Relocations
1 ...................
1
1 Relocations for 'MOVZ' and 'MOVK' instructions can be generated by
1 prefixing the label with '#:abs_g2:' etc. For example to load the
1 48-bit absolute address of FOO into x0:
1
1 movz x0, #:abs_g2:foo // bits 32-47, overflow check
1 movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
1 movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
1
1 Relocations for 'ADRP', and 'ADD', 'LDR' or 'STR' instructions can be
1 generated by prefixing the label with ':pg_hi21:' and '#:lo12:'
1 respectively.
1
1 For example to use 33-bit (+/-4GB) pc-relative addressing to load the
1 address of FOO into x0:
1
1 adrp x0, :pg_hi21:foo
1 add x0, x0, #:lo12:foo
1
1 Or to load the value of FOO into x0:
1
1 adrp x0, :pg_hi21:foo
1 ldr x0, [x0, #:lo12:foo]
1
1 Note that ':pg_hi21:' is optional.
1
1 adrp x0, foo
1
1 is equivalent to
1
1 adrp x0, :pg_hi21:foo
1