From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 89FF63858428 for ; Tue, 19 Jul 2022 05:40:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89FF63858428 Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id AE64066A7F; Tue, 19 Jul 2022 01:40:04 -0400 (EDT) Message-ID: <46caab90f1c0dd619ce2d609ba7038dd8ca8e179.camel@xry111.site> Subject: Re: [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types. From: Xi Ruoyao To: liuzhensong , binutils@sourceware.org Cc: xuchenghua@loongson.cn, mengqinggang@loongson.cn, WANG Xuerui Date: Tue, 19 Jul 2022 13:40:02 +0800 In-Reply-To: References: <20220718084316.390672-1-liuzhensong@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 MIME-Version: 1.0 X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, GIT_PATCH_0, LIKELY_SPAM_FROM, PDS_OTHER_BAD_TLD, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2022 05:40:09 -0000 On Tue, 2022-07-19 at 12:29 +0800, Xi Ruoyao via Binutils wrote: > On Mon, 2022-07-18 at 16:43 +0800, liuzhensong wrote: > > @@ -2427,7 +2453,7 @@ loongarch_elf_relocate_section (bfd > > *output_bfd, > > struct bfd_link_info *info, > > =C2=A0 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (h !=3D NULL) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 off =3D h->got.offset; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 off =3D h->got.offset & (~1); > > =C2=A0 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 if (off =3D=3D MINUS_ONE > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 && h->type !=3D STT_GNU_IFUNC) > > @@ -2455,79 +2481,76 @@ loongarch_elf_relocate_section (bfd > > *output_bfd, struct bfd_link_info *info, >=20 > This cannot be correct: after "off =3D h->got.offset & (~1)", how could > "off =3D=3D MINUS_ONE" be true? >=20 > Either you calculated "off" wrong, or you should remove the dead code. I guess you need the following changes. With those changes Glibc ifunc tests passed: diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 44b8d6dca9b..4d22ba037c8 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -2730,7 +2730,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, stru= ct bfd_link_info *info, { off =3D h->got.offset & (~1); =20 - if (off =3D=3D MINUS_ONE + if (h->got.offset =3D=3D MINUS_ONE && h->type !=3D STT_GNU_IFUNC) { fatal =3D (loongarch_reloc_is_fatal @@ -2742,7 +2742,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, stru= ct bfd_link_info *info, =20 /* Hidden symbol not has .got entry, only .got.plt entry so gprel is (plt - got). */ - if (off =3D=3D MINUS_ONE + if (h->got.offset =3D=3D MINUS_ONE && h->type =3D=3D STT_GNU_IFUNC) { if (h->plt.offset =3D=3D (bfd_vma) -1) --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University