[AArch64] Remove duplicated code when handling some GOT relocations types

Jiong Wang jiong.wang@foss.arm.com
Fri Jun 23 12:56:00 GMT 2017


I found there are quite a few duplicated code supporting several GP based
relocation types.  They are:

   BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
   BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
   BFD_RELOC_AARCH64_MOVW_GOTOFF_G1

These relocation types are supposed to be used for large memory model PIC/pic
mode under which we will have an initialized GP register points to the base of
GOT table, then these relocations are supposed to put the distance between GOT
entry and GOT table base address into the related instructions.

So, the parameters required to calculate the relocation should be the same as
BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15 etc, all of them are require the GOT entry
address and GOT table base address to perform the relocation.

This patch has removed those duplicated code when handling above listed
relocation types,  grouped them with others as relocation types that are
require GOT table base address during performing relocation, reused the
existed GOT handling code.

The relocation calculation for these types before and after this patch should be
identical.

No regression on native check-ld and cross check-binutils/as/ld/gcc/g++ though I
think there is no use of these relocations types in gcc yet.

OK for master?

bfd/
2017-06-23  Jiong Wang  <jiong.wang@arm.com>

	* elfnn-aarch64.c (aarch64_relocation_aginst_gp_p): New function.
	(elfNN_aarch64_final_link_relocate): Delete duplicated code for
	BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC,
	BFD_RELOC_AARCH64_MOVW_GOTOFF_G1.
	* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Optimize the
	support for them.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: simplify.patch
Type: text/x-patch
Size: 7146 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20170623/961ba99d/attachment.bin>


More information about the Binutils mailing list