From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1123) id 96AA03858D35; Tue, 23 May 2023 15:08:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96AA03858D35 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Matz To: bfd-cvs@sourceware.org Subject: [binutils-gdb] PR30437 aarch64: make RELA relocs idempotent X-Act-Checkin: binutils-gdb X-Git-Author: Michael Matz X-Git-Refname: refs/heads/master X-Git-Oldrev: d595715abc61b7df6747a99503b11b2e204ace30 X-Git-Newrev: 13a3cad698b3a757b1fcc938cc33e09a364ea47a Message-Id: <20230523150836.96AA03858D35@sourceware.org> Date: Tue, 23 May 2023 15:08:36 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 May 2023 15:08:36 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D13a3cad698b3= a757b1fcc938cc33e09a364ea47a commit 13a3cad698b3a757b1fcc938cc33e09a364ea47a Author: Michael Matz Date: Tue May 9 17:48:01 2023 +0200 PR30437 aarch64: make RELA relocs idempotent =20 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. =20 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 enco= de 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). =20 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). =20 bfd/ PR ld/30437 * elfnn-aarch64.c (elfNN_aarch64_howto_table): Clear src_mask if all relocation descriptors. =20 ld/ * testsuite/ld-aarch64/rela-idempotent.s: New testcase. * testsuite/ld-aarch64/rela-idempotent.d: New. * testsuite/ld-aarch64/aarch64-elf.exp: Run it. Diff: --- 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(-) 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[] =3D 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 */ =20 @@ -493,7 +493,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -508,7 +508,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -523,7 +523,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -538,7 +538,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -553,7 +553,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -571,7 +571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -586,7 +586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -601,7 +601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -616,7 +616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -631,7 +631,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -646,7 +646,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -661,7 +661,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -680,7 +680,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -695,7 +695,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -710,7 +710,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -728,7 +728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -743,7 +743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -758,7 +758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -773,7 +773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -788,7 +788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -803,7 +803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -818,7 +818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -836,7 +836,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -851,7 +851,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -866,7 +866,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -881,7 +881,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -896,7 +896,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -911,7 +911,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -928,7 +928,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -943,7 +943,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -958,7 +958,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -973,7 +973,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -988,7 +988,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =3D 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 */ =20 @@ -1003,7 +1003,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1018,7 +1018,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1033,7 +1033,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1049,7 +1049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1065,7 +1065,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1080,7 +1080,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1095,7 +1095,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1110,7 +1110,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1125,7 +1125,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1140,7 +1140,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1156,7 +1156,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1172,7 +1172,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1188,7 +1188,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1202,7 +1202,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1217,7 +1217,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1232,7 +1232,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1247,7 +1247,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1261,7 +1261,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1275,7 +1275,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1289,7 +1289,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1303,7 +1303,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1317,7 +1317,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1331,7 +1331,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1346,7 +1346,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1361,7 +1361,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1376,7 +1376,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1391,7 +1391,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1407,7 +1407,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1421,7 +1421,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1436,7 +1436,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1451,7 +1451,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1466,7 +1466,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1481,7 +1481,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1496,7 +1496,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1511,7 +1511,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1526,7 +1526,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1541,7 +1541,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1556,7 +1556,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1571,7 +1571,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1586,7 +1586,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1601,7 +1601,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1616,7 +1616,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1630,7 +1630,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1644,7 +1644,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1658,7 +1658,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1672,7 +1672,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1686,7 +1686,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1700,7 +1700,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1714,7 +1714,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1728,7 +1728,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1743,7 +1743,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1758,7 +1758,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1773,7 +1773,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1788,7 +1788,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1803,7 +1803,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1818,7 +1818,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1833,7 +1833,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1848,7 +1848,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1862,7 +1862,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1876,7 +1876,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1892,7 +1892,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1907,7 +1907,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1922,7 +1922,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1937,7 +1937,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1951,7 +1951,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -1965,7 +1965,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -2021,7 +2021,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -2035,7 +2035,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -2049,7 +2049,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 @@ -2063,7 +2063,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = =3D 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 */ =20 diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarc= h64/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" =20 +run_dump_test_lp64 "rela-idempotent" + run_dump_test_lp64 "pie-bind-locally" =20 run_dump_test "property-bti-pac1" diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.d b/ld/testsuite/ld-aa= rch64/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=3D0x100000 -Tdata=3D0x200000 -Trelocs.ld +#notarget: aarch64_be-*-* +#objdump: -dR -j .data +#... + +Disassembly of section .data: + +.* : + 200000: 00200032.* + 200000: R_AARCH64_RELATIVE \*ABS\*\+0x200032 + 200004: 00000000.* + +.* : + 200008: 00200054.* + 200008: R_AARCH64_RELATIVE \*ABS\*\+0x200054 + 20000c: 00000000.* diff --git a/ld/testsuite/ld-aarch64/rela-idempotent.s b/ld/testsuite/ld-aa= rch64/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