From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id D20483857B9D for ; Fri, 16 Sep 2022 20:11:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D20483857B9D Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1663359074; bh=5W1fGH/3nSXyNuuh6DoGwDtOTfYvEua1FkENEw1zbLg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=YON6RiI+KBX1TUMXiJjsYBGHT33uWttl0i0QwyJ6R0goiT4yAraT+o7ma/7/BYXXo myNE4CE4MCsOo0a+ODqJOVAhvJ/1gCEoM5u0zNIvVmc1WB2l+ofVkXPIzFgmWcFWYv vJDmcdeJBZo94G7i4z6HIQnDvzA1o2n6Vs9b3jZA= Received: from [IPv6:240e:358:119f:2b00:dc73:854d:832e:5] (unknown [IPv6:240e:358:119f:2b00:dc73:854d:832e:5]) (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 9C77A66776; Fri, 16 Sep 2022 16:11:11 -0400 (EDT) Message-ID: Subject: Re: [PATCH 2/2] LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs From: Xi Ruoyao To: liuzhensong , binutils@sourceware.org Cc: Lulu Cheng , Wang Xuerui , Chenghua Xu Date: Sat, 17 Sep 2022 04:11:06 +0800 In-Reply-To: <939eebd1-365d-72c5-5b2c-43bd6e0f1ff2@loongson.cn> References: <20220913154414.554861-1-xry111@xry111.site> <20220913154414.554861-3-xry111@xry111.site> <939eebd1-365d-72c5-5b2c-43bd6e0f1ff2@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 2022-09-15 at 21:03 +0800, liuzhensong wrote: > It May be unnecessary find the slot in section of .rela.dyn. >=20 > The slot of R_LARCH_IRELATIVE is within the scope relplt->contents (the= =20 > space >=20 > is calculated in function local_allocate_ifunc_dyn_relocs). >=20 > We can find the slot just in relplt->contents(Only for dynamic ifunc. I= =20 > did not test for static ifunc.). The problem is loongarch_elf_finish_dynamic_symbol runs after elf_link_sort_relocs. elf_link_sort_relocs basically does: (pseudo code) buffer =3D [] for section in {input of .rela.dyn} buffer +=3D (section.content) as [RELA] buffer.sort_by(some_comparator) buffer =3D buffer as [byte] for section in {input of .rela.dyn} section.content =3D buffer[..section.content.len()] buffer =3D buffer[section.content.len()..] So a "slot" in relplt->contents can end up elsewhere. You can read the code of elf_link_sort_relocs to see it... I can try to write a test case for this, but it's 04:00 AM now so I'd do it after a sleep... --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University