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

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


Hi all,

This is the assembler 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>

        * reloc.c: Add 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.
        * bfd-in2.h: Regenerate.
        * libbfd.h: Regenerate.
        * elfnn-aarch64.c (elfNN_aarch64_howto_table): Add entries for
	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.

gas/

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

	* config/tc-aarch64.c (reloc_table): add entries for
	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.
	(process_movw_reloc_info): Supports newly added MOVW_PREL relocations.
	(md_apply_fix): Likewise
	* testsuite/gas/aarch64/prel_g0.s: New.
	* testsuite/gas/aarch64/prel_g0.d: New.
	* testsuite/gas/aarch64/prel_g0_nc.s: New.
	* testsuite/gas/aarch64/prel_g0_nc.d: New.
	* testsuite/gas/aarch64/prel_g1.s: New.
	* testsuite/gas/aarch64/prel_g1.d: New.
	* testsuite/gas/aarch64/prel_g1_nc.s: New.
	* testsuite/gas/aarch64/prel_g1_nc.d: New.
	* testsuite/gas/aarch64/prel_g2.s: New.
	* testsuite/gas/aarch64/prel_g2.d: New.
	* testsuite/gas/aarch64/prel_g2_nc.s: New.
	* testsuite/gas/aarch64/prel_g2_nc.d: New.
	* testsuite/gas/aarch64/prel_g3.s: New.
	* testsuite/gas/aarch64/prel_g3.d: 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: 0001-GAS-AARCH64-Add-group-relocations-to-create-PC-relat.patch
Type: text/x-patch
Size: 21782 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180118/e156b793/attachment.bin>


More information about the Binutils mailing list