public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PR30437 aarch64: make RELA relocs idempotent
@ 2023-05-10 14:04 Michael Matz
  2023-05-17 14:35 ` Nick Clifton
  2023-05-24 15:26 ` Richard Earnshaw (lists)
  0 siblings, 2 replies; 11+ messages in thread
From: Michael Matz @ 2023-05-10 14:04 UTC (permalink / raw)
  To: binutils

normally RELA relocs in BFD should not consider the contents of the
relocated place.  The aarch64 psABI is even stricter, it specifies
(section 5.7.16) that all RELA relocs _must_ be idempotent.

Since the inception of the aarch64 BFD backend all the relocs have a
non-zero src_mask, and hence break this invariant.  It's normally not
a very visible problem as one can see it only when the relocated place
already contains a non-zero value, which usually only happens sometimes
when using 'ld -r' (or as in the testcase when jumping through hoops to
generate the relocations).  Or with alternative toolchains that do encode
stuff in the relocated places with the assumption that a relocation
to that place ignores whatever is there (as they can according to
the psABI).

Golang is such a toolchain and https://github.com/golang/go/issues/39927
is ultimately caused by this problem: the testcase testGCData failing
is caused by the garbage collection data-structure to describe a type
containing pointers to be wrong.  It's wrong because a field that's
supposed to contain a file-relative offset (to some gcbits) has a
relocation applied and that relocation has an addend which also is
already part of the go-produced object file (so the addend is
implicitely applied twice).

bfd/
	PR ld/30437
	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask
	if all relocation descriptors.

ld/
	* testsuite/ld-aarch64/rela-idempotent.s: New testcase.
	* testsuite/ld-aarch64/rela-idempotent.d: New.
	* testsuite/ld-aarch64/aarch64-elf.exp: Run it.
---

Tested for aarch64-elf and aarch64-linux (and the other ~150 targets, 
though those can't be affected).  Also tested natively on 
aarch64-suse-linux-gnu.  Okay for master?


Ciao,
Michael.

 bfd/elfnn-aarch64.c                       | 208 +++++++++++-----------
 ld/testsuite/ld-aarch64/aarch64-elf.exp   |   2 +
 ld/testsuite/ld-aarch64/rela-idempotent.d |  19 ++
 ld/testsuite/ld-aarch64/rela-idempotent.s |  14 ++
 4 files changed, 139 insertions(+), 104 deletions(-)
 create mode 100644 ld/testsuite/ld-aarch64/rela-idempotent.d
 create mode 100644 ld/testsuite/ld-aarch64/rela-idempotent.s

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index c23cbd3601a..32799b6b009 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -478,7 +478,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ABS64),	/* name */
 	 false,			/* partial_inplace */
-	 ALL_ONES,		/* src_mask */
+	 0,			/* src_mask */
 	 ALL_ONES,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -493,7 +493,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ABS32),	/* name */
 	 false,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -508,7 +508,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ABS16),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -523,7 +523,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (PREL64),	/* name */
 	 false,			/* partial_inplace */
-	 ALL_ONES,		/* src_mask */
+	 0,			/* src_mask */
 	 ALL_ONES,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -538,7 +538,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (PREL32),	/* name */
 	 false,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -553,7 +553,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (PREL16),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -571,7 +571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G0),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -586,7 +586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -601,7 +601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -616,7 +616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G1_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -631,7 +631,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G2),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -646,7 +646,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G2_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -661,7 +661,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_UABS_G3),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -680,7 +680,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_SABS_G0),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -695,7 +695,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_SABS_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -710,7 +710,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_SABS_G2),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -728,7 +728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G0),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -743,7 +743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -758,7 +758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -773,7 +773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G1_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -788,7 +788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G2),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -803,7 +803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G2_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -818,7 +818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_PREL_G3),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 true),		/* pcrel_offset */
 
@@ -836,7 +836,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD_PREL_LO19),	/* name */
 	 false,			/* partial_inplace */
-	 0x7ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7ffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -851,7 +851,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ADR_PREL_LO21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -866,7 +866,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ADR_PREL_PG_HI21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -881,7 +881,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ADR_PREL_PG_HI21_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -896,7 +896,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ADD_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -911,7 +911,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LDST8_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,				/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -928,7 +928,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TSTBR14),	/* name */
 	 false,			/* partial_inplace */
-	 0x3fff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3fff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -943,7 +943,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (CONDBR19),	/* name */
 	 false,			/* partial_inplace */
-	 0x7ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7ffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -958,7 +958,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (JUMP26),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -973,7 +973,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (CALL26),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -988,7 +988,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LDST16_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffe,			/* src_mask */
+	 0,			/* src_mask */
 	 0xffe,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1003,7 +1003,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LDST32_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc,			/* src_mask */
+	 0,			/* src_mask */
 	 0xffc,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1018,7 +1018,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LDST64_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xff8,			/* src_mask */
+	 0,			/* src_mask */
 	 0xff8,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1033,7 +1033,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LDST128_ABS_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xff0,			/* src_mask */
+	 0,			/* src_mask */
 	 0xff0,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1049,7 +1049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 AARCH64_R_STR (GOT_LD_PREL19),	/* name */
 	 false,				/* partial_inplace */
-	 0xffffe0,			/* src_mask */
+	 0,				/* src_mask */
 	 0xffffe0,			/* dst_mask */
 	 true),				/* pcrel_offset */
 
@@ -1065,7 +1065,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (ADR_GOT_PAGE),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1080,7 +1080,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD64_GOT_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xff8,			/* src_mask */
+	 0,			/* src_mask */
 	 0xff8,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1095,7 +1095,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD32_GOT_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc,			/* src_mask */
+	 0,			/* src_mask */
 	 0xffc,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1110,7 +1110,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_GOTOFF_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1125,7 +1125,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (MOVW_GOTOFF_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1140,7 +1140,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD64_GOTOFF_LO15),	/* name */
 	 false,			/* partial_inplace */
-	 0x7ff8,			/* src_mask */
+	 0,				/* src_mask */
 	 0x7ff8,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1156,7 +1156,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD32_GOTPAGE_LO14),	/* name */
 	 false,			/* partial_inplace */
-	 0x5ffc,		/* src_mask */
+	 0,			/* src_mask */
 	 0x5ffc,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1172,7 +1172,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (LD64_GOTPAGE_LO15),	/* name */
 	 false,			/* partial_inplace */
-	 0x7ff8,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7ff8,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1188,7 +1188,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSGD_ADR_PAGE21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1202,7 +1202,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSGD_ADR_PREL21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1217,7 +1217,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSGD_ADD_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1232,7 +1232,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSGD_MOVW_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1247,7 +1247,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSGD_MOVW_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1261,7 +1261,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_ADR_GOTTPREL_PAGE21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1275,7 +1275,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_LD64_GOTTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xff8,			/* src_mask */
+	 0,			/* src_mask */
 	 0xff8,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1289,7 +1289,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_LD32_GOTTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc,			/* src_mask */
+	 0,			/* src_mask */
 	 0xffc,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1303,7 +1303,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_LD_GOTTPREL_PREL19),	/* name */
 	 false,			/* partial_inplace */
-	 0x1ffffc,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1ffffc,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1317,7 +1317,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1331,7 +1331,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1346,7 +1346,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADD_DTPREL_HI12),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1361,7 +1361,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1376,7 +1376,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1391,7 +1391,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADD_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1407,7 +1407,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADR_PAGE21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1421,7 +1421,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_ADR_PREL21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1436,7 +1436,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x1ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1451,7 +1451,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x1ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1466,7 +1466,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1481,7 +1481,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1496,7 +1496,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1511,7 +1511,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x7fc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7fc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1526,7 +1526,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1541,7 +1541,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1556,7 +1556,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1571,7 +1571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1586,7 +1586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1601,7 +1601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1616,7 +1616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G2),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1630,7 +1630,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G2),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1644,7 +1644,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1658,7 +1658,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1672,7 +1672,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1686,7 +1686,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1700,7 +1700,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_ADD_TPREL_HI12),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1714,7 +1714,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1728,7 +1728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1743,7 +1743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x1ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1758,7 +1758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x1ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1773,7 +1773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1788,7 +1788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1803,7 +1803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x7fc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7fc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1818,7 +1818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x7fc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x7fc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1833,7 +1833,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1848,7 +1848,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0x3ffc00,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffc00,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1862,7 +1862,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_LD_PREL19),	/* name */
 	 false,			/* partial_inplace */
-	 0x0ffffe0,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0ffffe0,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1876,7 +1876,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_ADR_PREL21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1892,7 +1892,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_ADR_PAGE21),	/* name */
 	 false,			/* partial_inplace */
-	 0x1fffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x1fffff,		/* dst_mask */
 	 true),			/* pcrel_offset */
 
@@ -1907,7 +1907,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_LD64_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0xff8,			/* src_mask */
+	 0,			/* src_mask */
 	 0xff8,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1922,7 +1922,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_LD32_LO12_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffc,			/* src_mask */
+	 0,			/* src_mask */
 	 0xffc,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1937,7 +1937,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_ADD_LO12),	/* name */
 	 false,			/* partial_inplace */
-	 0xfff,			/* src_mask */
+	 0,			/* src_mask */
 	 0xfff,			/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1951,7 +1951,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_OFF_G1),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -1965,7 +1965,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (TLSDESC_OFF_G0_NC),	/* name */
 	 false,			/* partial_inplace */
-	 0xffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -2021,7 +2021,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (COPY),	/* name */
 	 true,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -2035,7 +2035,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (GLOB_DAT),	/* name */
 	 true,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -2049,7 +2049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (JUMP_SLOT),	/* name */
 	 true,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
@@ -2063,7 +2063,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 bfd_elf_generic_reloc,	/* special_function */
 	 AARCH64_R_STR (RELATIVE),	/* name */
 	 true,			/* partial_inplace */
-	 ALL_ONES,		/* src_mask */
+	 0,			/* src_mask */
 	 ALL_ONES,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index ec55bf49931..b025fcbd567 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -401,6 +401,8 @@ run_dump_test_lp64 "rela-abs-relative"
 run_dump_test_lp64 "rela-abs-relative-be"
 run_dump_test_lp64 "rela-abs-relative-opt"
 
+run_dump_test_lp64 "rela-idempotent"
+
 run_dump_test_lp64 "pie-bind-locally"
 
 run_dump_test "property-bti-pac1"
diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.d b/ld/testsuite/ld-aarch64/rela-idempotent.d
new file mode 100644
index 00000000000..f3b5ffb988b
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/rela-idempotent.d
@@ -0,0 +1,19 @@
+#name: rela-idempotent
+#source: rela-idempotent.s
+#target: [check_shared_lib_support]
+#ld: -shared -Ttext-segment=0x100000 -Tdata=0x200000 -Trelocs.ld
+#notarget: aarch64_be-*-*
+#objdump: -dR -j .data
+#...
+
+Disassembly of section .data:
+
+.* <l>:
+  200000:	00200032.*
+			200000: R_AARCH64_RELATIVE	\*ABS\*\+0x200032
+  200004:	00000000.*
+
+.* <q>:
+  200008:	00200054.*
+			200008: R_AARCH64_RELATIVE	\*ABS\*\+0x200054
+  20000c:	00000000.*
diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.s b/ld/testsuite/ld-aarch64/rela-idempotent.s
new file mode 100644
index 00000000000..7cb5dffb3bd
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/rela-idempotent.s
@@ -0,0 +1,14 @@
+# this checks that aarch64 RELA relocs are ignoring existing section
+# content of the relocated place
+       .text
+       .global _start
+_start:
+       ret
+
+       .data
+       .p2align 4
+l:     .long   0x11111111, 0x22222222
+q:     .quad   0x4444444433333333
+
+       .reloc l, BFD_RELOC_64, q+42
+       .reloc q, BFD_RELOC_64, l+84
-- 
2.39.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-10 14:04 [PATCH] PR30437 aarch64: make RELA relocs idempotent Michael Matz
@ 2023-05-17 14:35 ` Nick Clifton
  2023-05-24 15:26 ` Richard Earnshaw (lists)
  1 sibling, 0 replies; 11+ messages in thread
From: Nick Clifton @ 2023-05-17 14:35 UTC (permalink / raw)
  To: Michael Matz, binutils

Hi Michael,

> bfd/
> 	PR ld/30437
> 	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask
> 	if all relocation descriptors.
> 
> ld/
> 	* testsuite/ld-aarch64/rela-idempotent.s: New testcase.
> 	* testsuite/ld-aarch64/rela-idempotent.d: New.
> 	* testsuite/ld-aarch64/aarch64-elf.exp: Run it.
> ---
> 
> Tested for aarch64-elf and aarch64-linux (and the other ~150 targets,
> though those can't be affected).  Also tested natively on
> aarch64-suse-linux-gnu.  Okay for master?

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-10 14:04 [PATCH] PR30437 aarch64: make RELA relocs idempotent Michael Matz
  2023-05-17 14:35 ` Nick Clifton
@ 2023-05-24 15:26 ` Richard Earnshaw (lists)
  2023-05-24 16:03   ` Michael Matz
  2023-05-24 22:54   ` Alan Modra
  1 sibling, 2 replies; 11+ messages in thread
From: Richard Earnshaw (lists) @ 2023-05-24 15:26 UTC (permalink / raw)
  To: Michael Matz, binutils

On 10/05/2023 15:04, Michael Matz via Binutils wrote:
> normally RELA relocs in BFD should not consider the contents of the
> relocated place.  The aarch64 psABI is even stricter, it specifies
> (section 5.7.16) that all RELA relocs _must_ be idempotent.
> 
> Since the inception of the aarch64 BFD backend all the relocs have a
> non-zero src_mask, and hence break this invariant.  It's normally not
> a very visible problem as one can see it only when the relocated place
> already contains a non-zero value, which usually only happens sometimes
> when using 'ld -r' (or as in the testcase when jumping through hoops to
> generate the relocations).  Or with alternative toolchains that do encode
> stuff in the relocated places with the assumption that a relocation
> to that place ignores whatever is there (as they can according to
> the psABI).
> 
> Golang is such a toolchain and https://github.com/golang/go/issues/39927
> is ultimately caused by this problem: the testcase testGCData failing
> is caused by the garbage collection data-structure to describe a type
> containing pointers to be wrong.  It's wrong because a field that's
> supposed to contain a file-relative offset (to some gcbits) has a
> relocation applied and that relocation has an addend which also is
> already part of the go-produced object file (so the addend is
> implicitely applied twice).
> 
> bfd/
> 	PR ld/30437
> 	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask
> 	if all relocation descriptors.
> 
> ld/
> 	* testsuite/ld-aarch64/rela-idempotent.s: New testcase.
> 	* testsuite/ld-aarch64/rela-idempotent.d: New.
> 	* testsuite/ld-aarch64/aarch64-elf.exp: Run it.
> ---
> 
> Tested for aarch64-elf and aarch64-linux (and the other ~150 targets,
> though those can't be affected).  Also tested natively on
> aarch64-suse-linux-gnu.  Okay for master?
> 

Isn't this what partial_inplace is supposed to describe?  Since that's 
false, I'd expect any value stored in the section contents to be ignored.

R.

> 
> Ciao,
> Michael.
> 
>   bfd/elfnn-aarch64.c                       | 208 +++++++++++-----------
>   ld/testsuite/ld-aarch64/aarch64-elf.exp   |   2 +
>   ld/testsuite/ld-aarch64/rela-idempotent.d |  19 ++
>   ld/testsuite/ld-aarch64/rela-idempotent.s |  14 ++
>   4 files changed, 139 insertions(+), 104 deletions(-)
>   create mode 100644 ld/testsuite/ld-aarch64/rela-idempotent.d
>   create mode 100644 ld/testsuite/ld-aarch64/rela-idempotent.s
> 
> diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
> index c23cbd3601a..32799b6b009 100644
> --- a/bfd/elfnn-aarch64.c
> +++ b/bfd/elfnn-aarch64.c
> @@ -478,7 +478,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ABS64),	/* name */
>   	 false,			/* partial_inplace */
> -	 ALL_ONES,		/* src_mask */
> +	 0,			/* src_mask */
>   	 ALL_ONES,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -493,7 +493,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ABS32),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffffffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -508,7 +508,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ABS16),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -523,7 +523,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (PREL64),	/* name */
>   	 false,			/* partial_inplace */
> -	 ALL_ONES,		/* src_mask */
> +	 0,			/* src_mask */
>   	 ALL_ONES,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -538,7 +538,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (PREL32),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffffffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -553,7 +553,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (PREL16),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -571,7 +571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G0),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -586,7 +586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -601,7 +601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -616,7 +616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G1_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -631,7 +631,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G2),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -646,7 +646,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G2_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -661,7 +661,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_UABS_G3),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -680,7 +680,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_SABS_G0),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -695,7 +695,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_SABS_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -710,7 +710,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_SABS_G2),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -728,7 +728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G0),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -743,7 +743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -758,7 +758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -773,7 +773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G1_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -788,7 +788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G2),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -803,7 +803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G2_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -818,7 +818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_PREL_G3),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 true),		/* pcrel_offset */
>   
> @@ -836,7 +836,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD_PREL_LO19),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7ffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7ffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -851,7 +851,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ADR_PREL_LO21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -866,7 +866,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ADR_PREL_PG_HI21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -881,7 +881,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ADR_PREL_PG_HI21_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -896,7 +896,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ADD_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -911,7 +911,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LDST8_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,				/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -928,7 +928,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TSTBR14),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3fff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3fff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -943,7 +943,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (CONDBR19),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7ffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7ffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -958,7 +958,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (JUMP26),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -973,7 +973,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (CALL26),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -988,7 +988,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LDST16_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffe,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffe,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1003,7 +1003,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LDST32_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1018,7 +1018,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LDST64_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xff8,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xff8,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1033,7 +1033,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LDST128_ABS_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xff0,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xff0,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1049,7 +1049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,		/* special_function */
>   	 AARCH64_R_STR (GOT_LD_PREL19),	/* name */
>   	 false,				/* partial_inplace */
> -	 0xffffe0,			/* src_mask */
> +	 0,				/* src_mask */
>   	 0xffffe0,			/* dst_mask */
>   	 true),				/* pcrel_offset */
>   
> @@ -1065,7 +1065,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (ADR_GOT_PAGE),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1080,7 +1080,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD64_GOT_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xff8,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xff8,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1095,7 +1095,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD32_GOT_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1110,7 +1110,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_GOTOFF_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1125,7 +1125,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (MOVW_GOTOFF_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1140,7 +1140,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD64_GOTOFF_LO15),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7ff8,			/* src_mask */
> +	 0,				/* src_mask */
>   	 0x7ff8,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1156,7 +1156,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD32_GOTPAGE_LO14),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x5ffc,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x5ffc,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1172,7 +1172,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (LD64_GOTPAGE_LO15),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7ff8,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7ff8,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1188,7 +1188,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSGD_ADR_PAGE21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1202,7 +1202,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSGD_ADR_PREL21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1217,7 +1217,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSGD_ADD_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1232,7 +1232,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSGD_MOVW_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1247,7 +1247,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSGD_MOVW_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1261,7 +1261,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_ADR_GOTTPREL_PAGE21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1275,7 +1275,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_LD64_GOTTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xff8,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xff8,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1289,7 +1289,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_LD32_GOTTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1303,7 +1303,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_LD_GOTTPREL_PREL19),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1ffffc,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1ffffc,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1317,7 +1317,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1331,7 +1331,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1346,7 +1346,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADD_DTPREL_HI12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1361,7 +1361,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1376,7 +1376,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1391,7 +1391,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADD_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1407,7 +1407,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADR_PAGE21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1421,7 +1421,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_ADR_PREL21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1436,7 +1436,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1451,7 +1451,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1466,7 +1466,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1481,7 +1481,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1496,7 +1496,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1511,7 +1511,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7fc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7fc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1526,7 +1526,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1541,7 +1541,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1556,7 +1556,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1571,7 +1571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1586,7 +1586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1601,7 +1601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1616,7 +1616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLD_MOVW_DTPREL_G2),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1630,7 +1630,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G2),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1644,7 +1644,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1658,7 +1658,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1672,7 +1672,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1686,7 +1686,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1700,7 +1700,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_ADD_TPREL_HI12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1714,7 +1714,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1728,7 +1728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1743,7 +1743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1758,7 +1758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1773,7 +1773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1788,7 +1788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1803,7 +1803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7fc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7fc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1818,7 +1818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x7fc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x7fc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1833,7 +1833,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1848,7 +1848,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x3ffc00,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x3ffc00,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1862,7 +1862,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_LD_PREL19),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x0ffffe0,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x0ffffe0,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1876,7 +1876,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_ADR_PREL21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1892,7 +1892,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_ADR_PAGE21),	/* name */
>   	 false,			/* partial_inplace */
> -	 0x1fffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0x1fffff,		/* dst_mask */
>   	 true),			/* pcrel_offset */
>   
> @@ -1907,7 +1907,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_LD64_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xff8,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xff8,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1922,7 +1922,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_LD32_LO12_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffc,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffc,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1937,7 +1937,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_ADD_LO12),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xfff,			/* src_mask */
> +	 0,			/* src_mask */
>   	 0xfff,			/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1951,7 +1951,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_OFF_G1),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -1965,7 +1965,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (TLSDESC_OFF_G0_NC),	/* name */
>   	 false,			/* partial_inplace */
> -	 0xffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -2021,7 +2021,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (COPY),	/* name */
>   	 true,			/* partial_inplace */
> -	 0xffffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffffffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -2035,7 +2035,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (GLOB_DAT),	/* name */
>   	 true,			/* partial_inplace */
> -	 0xffffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffffffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -2049,7 +2049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (JUMP_SLOT),	/* name */
>   	 true,			/* partial_inplace */
> -	 0xffffffff,		/* src_mask */
> +	 0,			/* src_mask */
>   	 0xffffffff,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> @@ -2063,7 +2063,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
>   	 bfd_elf_generic_reloc,	/* special_function */
>   	 AARCH64_R_STR (RELATIVE),	/* name */
>   	 true,			/* partial_inplace */
> -	 ALL_ONES,		/* src_mask */
> +	 0,			/* src_mask */
>   	 ALL_ONES,		/* dst_mask */
>   	 false),		/* pcrel_offset */
>   
> diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
> index ec55bf49931..b025fcbd567 100644
> --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
> +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
> @@ -401,6 +401,8 @@ run_dump_test_lp64 "rela-abs-relative"
>   run_dump_test_lp64 "rela-abs-relative-be"
>   run_dump_test_lp64 "rela-abs-relative-opt"
>   
> +run_dump_test_lp64 "rela-idempotent"
> +
>   run_dump_test_lp64 "pie-bind-locally"
>   
>   run_dump_test "property-bti-pac1"
> diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.d b/ld/testsuite/ld-aarch64/rela-idempotent.d
> new file mode 100644
> index 00000000000..f3b5ffb988b
> --- /dev/null
> +++ b/ld/testsuite/ld-aarch64/rela-idempotent.d
> @@ -0,0 +1,19 @@
> +#name: rela-idempotent
> +#source: rela-idempotent.s
> +#target: [check_shared_lib_support]
> +#ld: -shared -Ttext-segment=0x100000 -Tdata=0x200000 -Trelocs.ld
> +#notarget: aarch64_be-*-*
> +#objdump: -dR -j .data
> +#...
> +
> +Disassembly of section .data:
> +
> +.* <l>:
> +  200000:	00200032.*
> +			200000: R_AARCH64_RELATIVE	\*ABS\*\+0x200032
> +  200004:	00000000.*
> +
> +.* <q>:
> +  200008:	00200054.*
> +			200008: R_AARCH64_RELATIVE	\*ABS\*\+0x200054
> +  20000c:	00000000.*
> diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.s b/ld/testsuite/ld-aarch64/rela-idempotent.s
> new file mode 100644
> index 00000000000..7cb5dffb3bd
> --- /dev/null
> +++ b/ld/testsuite/ld-aarch64/rela-idempotent.s
> @@ -0,0 +1,14 @@
> +# this checks that aarch64 RELA relocs are ignoring existing section
> +# content of the relocated place
> +       .text
> +       .global _start
> +_start:
> +       ret
> +
> +       .data
> +       .p2align 4
> +l:     .long   0x11111111, 0x22222222
> +q:     .quad   0x4444444433333333
> +
> +       .reloc l, BFD_RELOC_64, q+42
> +       .reloc q, BFD_RELOC_64, l+84


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-24 15:26 ` Richard Earnshaw (lists)
@ 2023-05-24 16:03   ` Michael Matz
  2023-05-25  9:35     ` Richard Earnshaw (lists)
  2023-05-24 22:54   ` Alan Modra
  1 sibling, 1 reply; 11+ messages in thread
From: Michael Matz @ 2023-05-24 16:03 UTC (permalink / raw)
  To: Richard Earnshaw (lists); +Cc: binutils

Hello,

On Wed, 24 May 2023, Richard Earnshaw (lists) wrote:

> > Tested for aarch64-elf and aarch64-linux (and the other ~150 targets,
> > though those can't be affected).  Also tested natively on
> > aarch64-suse-linux-gnu.  Okay for master?
> > 
> 
> Isn't this what partial_inplace is supposed to describe?  Since that's 
> false, I'd expect any value stored in the section contents to be 
> ignored.

One might think so, yes.  But in practice that doesn't seem to be the case 
(anymore?).  I can't quite wrap my head around the logic in reloc.c and 
interaction between partial_inplace and src_mask.  The documentation says 
that partial_inplace _and_ src_mask should be zero for RELA targets (or 
rather, that other values are suspicious), and obviously having the 
former, but not the latter does make a difference.  (FWIW, x86_64 recently 
was fixed as well to have zero src_mask, and most other RELA targets also 
have it zero)

It's possible that partial_inplace only affects partial links (ld -r), at 
least the docu for that field specifically talks about only that, whereas 
here (the go bug) we have the problem of a final link where the section 
contents are non-zero.  I don't know if partial_inplace should or should 
not also affect final links, and if it's a bug that src_mask matters even 
with !partial_replace.  But one of the two needs to yield: either the 
logic regarding partial_inplace in reloc.c (so that src_mask isn't 
relevant anymore), or src_mask needs to be zero.  The advantage of the 
latter change is that it's aarch64-specific, whereas a change to 
partial_inplace handling affects everything and needs more bravery than I 
have.

Either way, even _if_ partial_inplace would be made so that src_mask 
doesn't matter anymore, then the change to zero src_mask would then still 
be at least harmless.

(skimming some more uses of src_mask relative to uses of partial_inplace 
in the aarch64 target also shows some more possibly dubious consideration 
of original section contents in _bfd_aarch64_elf_put_addend.  It always 
looks at the original content and uses src_mask as selector of being for 
insns or data, but then goes on to mask the read contents only against 
dst_mask, and not against src_mask.  I don't quite know what to make of 
that) 


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-24 15:26 ` Richard Earnshaw (lists)
  2023-05-24 16:03   ` Michael Matz
@ 2023-05-24 22:54   ` Alan Modra
  1 sibling, 0 replies; 11+ messages in thread
From: Alan Modra @ 2023-05-24 22:54 UTC (permalink / raw)
  To: Richard Earnshaw (lists); +Cc: Michael Matz, binutils

On Wed, May 24, 2023 at 04:26:03PM +0100, Richard Earnshaw (lists) via Binutils wrote:
> > 	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask
> > 	if all relocation descriptors.

> Isn't this what partial_inplace is supposed to describe?

Strictly speaking that flag describes what should be done for ld -r.
It has no effect on final link.  It does also affect what is produced
by gas (which is by far the messiest and most confusing part of libbfd
relocation processing).

>  Since that's
> false, I'd expect any value stored in the section contents to be ignored.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-24 16:03   ` Michael Matz
@ 2023-05-25  9:35     ` Richard Earnshaw (lists)
  2023-05-25 12:29       ` Michael Matz
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Earnshaw (lists) @ 2023-05-25  9:35 UTC (permalink / raw)
  To: Michael Matz; +Cc: binutils

On 24/05/2023 17:03, Michael Matz via Binutils wrote:
> Hello,
> 
> On Wed, 24 May 2023, Richard Earnshaw (lists) wrote:
> 
>>> Tested for aarch64-elf and aarch64-linux (and the other ~150 targets,
>>> though those can't be affected).  Also tested natively on
>>> aarch64-suse-linux-gnu.  Okay for master?
>>>
>>
>> Isn't this what partial_inplace is supposed to describe?  Since that's
>> false, I'd expect any value stored in the section contents to be
>> ignored.
> 
> One might think so, yes.  But in practice that doesn't seem to be the case
> (anymore?).  I can't quite wrap my head around the logic in reloc.c and
> interaction between partial_inplace and src_mask.  The documentation says
> that partial_inplace _and_ src_mask should be zero for RELA targets (or
> rather, that other values are suspicious), and obviously having the
> former, but not the latter does make a difference.  (FWIW, x86_64 recently
> was fixed as well to have zero src_mask, and most other RELA targets also
> have it zero)
> 
> It's possible that partial_inplace only affects partial links (ld -r), at
> least the docu for that field specifically talks about only that, whereas
> here (the go bug) we have the problem of a final link where the section
> contents are non-zero.  I don't know if partial_inplace should or should
> not also affect final links, and if it's a bug that src_mask matters even
> with !partial_replace.  But one of the two needs to yield: either the
> logic regarding partial_inplace in reloc.c (so that src_mask isn't
> relevant anymore), or src_mask needs to be zero.  The advantage of the
> latter change is that it's aarch64-specific, whereas a change to
> partial_inplace handling affects everything and needs more bravery than I
> have.
> 
> Either way, even _if_ partial_inplace would be made so that src_mask
> doesn't matter anymore, then the change to zero src_mask would then still
> be at least harmless.
> 
> (skimming some more uses of src_mask relative to uses of partial_inplace
> in the aarch64 target also shows some more possibly dubious consideration
> of original section contents in _bfd_aarch64_elf_put_addend.  It always
> looks at the original content and uses src_mask as selector of being for
> insns or data, but then goes on to mask the read contents only against
> dst_mask, and not against src_mask.  I don't quite know what to make of
> that)
> 
> 
> Ciao,
> Michael.

Thanks for the detailed explanation.  That makes sense, overall.  However...

I didn't think we had separate relocation rules for REL/RELA format 
relocs.  I know that we recommend RELA for aarch64, but how would an 
object file with REL format relocs be handled if src_mask is always zero?

R.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-25  9:35     ` Richard Earnshaw (lists)
@ 2023-05-25 12:29       ` Michael Matz
  2023-05-25 13:22         ` Richard Earnshaw (lists)
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Matz @ 2023-05-25 12:29 UTC (permalink / raw)
  To: Richard Earnshaw (lists); +Cc: binutils

Hello,

On Thu, 25 May 2023, Richard Earnshaw (lists) wrote:

> Thanks for the detailed explanation.  That makes sense, overall.  However...
> 
> I didn't think we had separate relocation rules for REL/RELA format 
> relocs.  I know that we recommend RELA for aarch64, but how would an 
> object file with REL format relocs be handled if src_mask is always 
> zero?

Right now the aarch64 bfd backend only support RELA 
(elf_backend_may_use_rel_p is off).  elf64-mips is an example that 
supports both, and it has separate howto tables for rel and rela 
descriptors (e.g. mips_elf64_howto_table_rel and 
mips_elf64_howto_table_rela), with the appropriate 
src_mask/partial_inplace settings depending on rel/rela:

  HOWTO (R_MIPS_32,             /* type */
         ...
         true,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */

vs.

  HOWTO (R_MIPS_32,             /* type */
         ...
         false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */

the rtype_to_howto backend routine appropriately switches between those 
depending on side-info passed in parameters.  (Whereas the name_lookup and 
type_lookup routines always use the rela tables and contain a FIXME 
comment to that effect :) ).  Various non-mips embedded targets try to 
also support this, but often only for read-in, not for generating both 
types of relocs, and so get away with only one howto table.  (I believe (!)
mips is the only one that actively tries to get REL+RELA support correct).


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-25 12:29       ` Michael Matz
@ 2023-05-25 13:22         ` Richard Earnshaw (lists)
  2023-05-25 14:12           ` Michael Matz
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Earnshaw (lists) @ 2023-05-25 13:22 UTC (permalink / raw)
  To: Michael Matz; +Cc: binutils

On 25/05/2023 13:29, Michael Matz via Binutils wrote:
> Hello,
> 
> On Thu, 25 May 2023, Richard Earnshaw (lists) wrote:
> 
>> Thanks for the detailed explanation.  That makes sense, overall.  However...
>>
>> I didn't think we had separate relocation rules for REL/RELA format
>> relocs.  I know that we recommend RELA for aarch64, but how would an
>> object file with REL format relocs be handled if src_mask is always
>> zero?
> 
> Right now the aarch64 bfd backend only support RELA
> (elf_backend_may_use_rel_p is off).  elf64-mips is an example that
> supports both, and it has separate howto tables for rel and rela
> descriptors (e.g. mips_elf64_howto_table_rel and
> mips_elf64_howto_table_rela), with the appropriate
> src_mask/partial_inplace settings depending on rel/rela:
> 
>    HOWTO (R_MIPS_32,             /* type */
>           ...
>           true,                  /* partial_inplace */
>           0xffffffff,            /* src_mask */
>           0xffffffff,            /* dst_mask */
> 
> vs.
> 
>    HOWTO (R_MIPS_32,             /* type */
>           ...
>           false,                 /* partial_inplace */
>           0,                     /* src_mask */
>           0xffffffff,            /* dst_mask */
> 
> the rtype_to_howto backend routine appropriately switches between those
> depending on side-info passed in parameters.  (Whereas the name_lookup and
> type_lookup routines always use the rela tables and contain a FIXME
> comment to that effect :) ).  Various non-mips embedded targets try to
> also support this, but often only for read-in, not for generating both
> types of relocs, and so get away with only one howto table.  (I believe (!)
> mips is the only one that actively tries to get REL+RELA support correct).
> 
> 
> Ciao,
> Michael.

I'd be surprised if even that is totally correct.  ELF permits 
relocations of a single 'place' to be chained provided that they are of 
the same type (all REL or all RELA); not that I've ever seen that done 
in practice.  When this is done the addend for the second and subsequent 
relocations use the result of the previous relocation - they must be 
processed in order.  Only the last relocation in a sequence writes a 
value back to the location being relocated.

So really, we shouldn't need two tables, we just need to know where to 
get the addend value from at the start of a chain.

R.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-25 13:22         ` Richard Earnshaw (lists)
@ 2023-05-25 14:12           ` Michael Matz
  2023-05-25 15:56             ` Richard Earnshaw (lists)
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Matz @ 2023-05-25 14:12 UTC (permalink / raw)
  To: Richard Earnshaw (lists); +Cc: binutils

Hello,

On Thu, 25 May 2023, Richard Earnshaw (lists) wrote:

> I'd be surprised if even that is totally correct.  ELF permits 
> relocations of a single 'place' to be chained provided that they are of 
> the same type (all REL or all RELA); not that I've ever seen that done 
> in practice.  When this is done the addend for the second and subsequent 
> relocations use the result of the previous relocation - they must be 
> processed in order.  Only the last relocation in a sequence writes a 
> value back to the location being relocated.
> 
> So really, we shouldn't need two tables, we just need to know where to 
> get the addend value from at the start of a chain.

Sort of, except ... it's not just for a chain of relocs (to the same 
place) steming from a single input file, but also about the similar 
situation when the same place is relocated multiple times due to 'ld -r' 
or pre-existing (non-zero) section content in an input file to a final 
link.  In this situation it's not easily determined what's the start of a 
reloc chain.

I still agree with you that abstractly multiple howto tables shouldn't be 
needed, because RELA relocs _always_ should ignore section content on 
read-in, and hence the reloc routines could simply special-case the 
RELA/REL distinction by just not looking at src_mask or partial_inplace 
for RELA relocs.  It's just that BFD isn't structured in this way.  
The internal representation of relocs always has an addend, no matter if 
it comes from read-in section contents or a RELA reloc, and the 
information of where it came from is lost (and section content isn't 
zeroed on read-in for REL relocs, when transferring the addend to the bfd 
reloc structure).  So, to get this all somewhat working correctly right 
now multiple howto entries are necessary (or special-casing target 
reloc-swap-in and swap-out routines).

I'm totally sure, once one tries to _really_ start mixing REL and RELA 
relocs in a link, at the latest when ld -r and/or other toolchains are 
involved, that a heap of bugs will be uncovered :-)

(And of course, it's always possible that REL relocations cannot always be 
used to achieve idempotence even in presence of 'ld -r', in which case 
RELA must be used.  The aarch64 psABI thankfully even spells this out.)


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-25 14:12           ` Michael Matz
@ 2023-05-25 15:56             ` Richard Earnshaw (lists)
  2023-05-25 16:01               ` Michael Matz
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Earnshaw (lists) @ 2023-05-25 15:56 UTC (permalink / raw)
  To: Michael Matz; +Cc: binutils

On 25/05/2023 15:12, Michael Matz via Binutils wrote:
> Hello,
> 
> On Thu, 25 May 2023, Richard Earnshaw (lists) wrote:
> 
>> I'd be surprised if even that is totally correct.  ELF permits
>> relocations of a single 'place' to be chained provided that they are of
>> the same type (all REL or all RELA); not that I've ever seen that done
>> in practice.  When this is done the addend for the second and subsequent
>> relocations use the result of the previous relocation - they must be
>> processed in order.  Only the last relocation in a sequence writes a
>> value back to the location being relocated.
>>
>> So really, we shouldn't need two tables, we just need to know where to
>> get the addend value from at the start of a chain.
> 
> Sort of, except ... it's not just for a chain of relocs (to the same
> place) steming from a single input file, but also about the similar
> situation when the same place is relocated multiple times due to 'ld -r'
> or pre-existing (non-zero) section content in an input file to a final
> link.  In this situation it's not easily determined what's the start of a
> reloc chain.
> 
> I still agree with you that abstractly multiple howto tables shouldn't be
> needed, because RELA relocs _always_ should ignore section content on
> read-in, and hence the reloc routines could simply special-case the
> RELA/REL distinction by just not looking at src_mask or partial_inplace
> for RELA relocs.  It's just that BFD isn't structured in this way.
> The internal representation of relocs always has an addend, no matter if
> it comes from read-in section contents or a RELA reloc, and the
> information of where it came from is lost (and section content isn't
> zeroed on read-in for REL relocs, when transferring the addend to the bfd
> reloc structure).  So, to get this all somewhat working correctly right
> now multiple howto entries are necessary (or special-casing target
> reloc-swap-in and swap-out routines).
> 
> I'm totally sure, once one tries to _really_ start mixing REL and RELA
> relocs in a link, at the latest when ld -r and/or other toolchains are
> involved, that a heap of bugs will be uncovered :-)

It shouldn't be a big problem because ELF says it's undefined if the 
different types of reloc target the same location.  IF they're 
addressing different (presumed non-overlapping) locations then the 
ordering shouldn't matter.

> 
> (And of course, it's always possible that REL relocations cannot always be
> used to achieve idempotence even in presence of 'ld -r', in which case
> RELA must be used.  The aarch64 psABI thankfully even spells this out.)
> 

There's no fundamental reason why a toolchain doing 'ld -r' can't always 
emit RELA format relocs, even if the input format was REL.  In fact, I'd 
argue that really it has to in most cases as 'ld -r' destroys the 
information that's needed to reprocess the relocations.

But I agree with you, this is all likely broken in BFD because we have 
no way of testing it (gas can't create multiple relocs to a single 
location to the best of my knowledge).

R.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PR30437 aarch64: make RELA relocs idempotent
  2023-05-25 15:56             ` Richard Earnshaw (lists)
@ 2023-05-25 16:01               ` Michael Matz
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Matz @ 2023-05-25 16:01 UTC (permalink / raw)
  To: Richard Earnshaw (lists); +Cc: binutils

Hello,

On Thu, 25 May 2023, Richard Earnshaw (lists) wrote:

> > (And of course, it's always possible that REL relocations cannot always be
> > used to achieve idempotence even in presence of 'ld -r', in which case
> > RELA must be used.  The aarch64 psABI thankfully even spells this out.)
> 
> There's no fundamental reason why a toolchain doing 'ld -r' can't always emit
> RELA format relocs, even if the input format was REL.  In fact, I'd argue that
> really it has to in most cases as 'ld -r' destroys the information that's
> needed to reprocess the relocations.

Right.

> But I agree with you, this is all likely broken in BFD because we have 
> no way of testing it (gas can't create multiple relocs to a single 
> location to the best of my knowledge).

With the .reloc directive it should be possible.  But if you try to do 
that you probably go down a rabbit hole of strange and wonderful 
proportions :)


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-25 16:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-10 14:04 [PATCH] PR30437 aarch64: make RELA relocs idempotent Michael Matz
2023-05-17 14:35 ` Nick Clifton
2023-05-24 15:26 ` Richard Earnshaw (lists)
2023-05-24 16:03   ` Michael Matz
2023-05-25  9:35     ` Richard Earnshaw (lists)
2023-05-25 12:29       ` Michael Matz
2023-05-25 13:22         ` Richard Earnshaw (lists)
2023-05-25 14:12           ` Michael Matz
2023-05-25 15:56             ` Richard Earnshaw (lists)
2023-05-25 16:01               ` Michael Matz
2023-05-24 22:54   ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).