[Binutils][AARCH64][0/2]Add group relocations to create PC-relative offset.

Renlin Li renlin.li@foss.arm.com
Thu Jan 18 15:34:00 GMT 2018


Hi all,

This is a patch to add Group relocations to create a
16, 32, 48, or 64 bit PC-relative offset inline.

The following relocations are added along with the test cases:
BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G3.


The operations for those relocations are: S + A - P.
S is the address of the symbol.
A is the addend for the relocation.
P is the address of the place being relocated

Those relocations are used to create PC-relative offset. For example,
The following code sequence could get the full address of _start.

.Ltmp1:
movz	x0, :prel_g2: _start - .Ltmp1
movk	x0, :prel_g1_nc: _start - .Ltmp1
movk	x0, :prel_g0_nc: _start - .Ltmp1
adr	x1, .Ltmp1
add	x0, x0, x1

binutils regression test checked OK, linux kernel link checked OK.
OK to commit?

Regards,
Renlin



More information about the Binutils mailing list