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

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


Hi all,

This is the lnker part support for the following relocations:

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

Regards,
Renlin

bfd/

2018-01-18  Renlin Li  <renlin.li@arm.com>

	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Add support.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/

2018-01-18  Renlin Li  <renlin.li@arm.com>

	* testsuite/ld-aarch64/aarch64-elf.exp: Run new testes.
	* testsuite/ld-aarch64/emit-relocs-287.s: Fix test case.
	* testsuite/ld-aarch64/emit-relocs-287.d: Fix expected output.
	* testsuite/ld-aarch64/emit-relocs-287-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-287-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-288.d: New.
	* testsuite/ld-aarch64/emit-relocs-288.s: New.
	* testsuite/ld-aarch64/emit-relocs-289.d: New.
	* testsuite/ld-aarch64/emit-relocs-289.s: New.
	* testsuite/ld-aarch64/emit-relocs-289-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-289-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-290.d: New.
	* testsuite/ld-aarch64/emit-relocs-290.s: New.
	* testsuite/ld-aarch64/emit-relocs-291.d: New.
	* testsuite/ld-aarch64/emit-relocs-291.s: New.
	* testsuite/ld-aarch64/emit-relocs-291-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-291-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-292.d: New.
	* testsuite/ld-aarch64/emit-relocs-292.s: New.
	* testsuite/ld-aarch64/emit-relocs-293.d: New.
	* testsuite/ld-aarch64/emit-relocs-293.s: New.


On 18/01/18 15:34, Renlin Li wrote:
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-LD-AARCH64-Add-group-relocations-to-create-PC-relati.patch
Type: text/x-patch
Size: 16075 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180118/05006f45/attachment.bin>


More information about the Binutils mailing list