aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-aarch64.c
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2017-06-29 11:45:24 +0100
committerJiong Wang <jiong.wang@arm.com>2017-06-29 11:45:24 +0100
commit2aff25ba76035d2f1f48ea8a6c4b7e498ee31790 (patch)
tree37844c556138183a2811f1f17e3025992ad5537b /bfd/elfxx-aarch64.c
parent88ab90e860a46a1123fcfd13bfe51cd360e9c3f7 (diff)
downloadgdb-2aff25ba76035d2f1f48ea8a6c4b7e498ee31790.zip
gdb-2aff25ba76035d2f1f48ea8a6c4b7e498ee31790.tar.gz
gdb-2aff25ba76035d2f1f48ea8a6c4b7e498ee31790.tar.bz2
[AArch64] Remove duplicated code when handling some GOT relocations types
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. bfd/ * 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.
Diffstat (limited to 'bfd/elfxx-aarch64.c')
-rw-r--r--bfd/elfxx-aarch64.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index 6c61ec6..10ee5fa 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -413,7 +413,6 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
case BFD_RELOC_AARCH64_16:
case BFD_RELOC_AARCH64_32:
- case BFD_RELOC_AARCH64_LD64_GOTOFF_LO15:
case BFD_RELOC_AARCH64_MOVW_G0:
case BFD_RELOC_AARCH64_MOVW_G0_NC:
case BFD_RELOC_AARCH64_MOVW_G0_S:
@@ -424,8 +423,6 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
case BFD_RELOC_AARCH64_MOVW_G2_NC:
case BFD_RELOC_AARCH64_MOVW_G2_S:
case BFD_RELOC_AARCH64_MOVW_G3:
- case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
- case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1:
case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC:
@@ -468,10 +465,15 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
value = PG (value + addend) - PG (place);
break;
+ /* Caller must make sure addend is the base address of .got section. */
case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14:
case BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15:
- /* Caller must make sure addend is the base address of .got section. */
- value = value - PG (addend);
+ addend = PG (addend);
+ /* Fall through. */
+ case BFD_RELOC_AARCH64_LD64_GOTOFF_LO15:
+ case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
+ case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1:
+ value = value - addend;
break;
case BFD_RELOC_AARCH64_ADD_LO12: