From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id AAB27385841D for ; Thu, 28 Jul 2022 08:26:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AAB27385841D Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 03D5F116824; Thu, 28 Jul 2022 04:26:44 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id A9-HnyEuUmwG; Thu, 28 Jul 2022 04:26:43 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 5EFA8116816; Thu, 28 Jul 2022 04:26:43 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 26S8QURW1824261 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 05:26:32 -0300 From: Alexandre Oliva To: "H.J. Lu" Cc: GCC Patches , Jan Hubicka , Uros Bizjak Subject: Re: [PATCH] [PR83782] i386 PIE: avoid @GOTOFF for ifuncs and their aliases Organization: Free thinker, does not speak for AdaCore References: Errors-To: aoliva@lxoliva.fsfla.org Date: Thu, 28 Jul 2022 05:26:30 -0300 In-Reply-To: (H. J. Lu's message of "Wed, 27 Jul 2022 07:31:38 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2022 08:26:48 -0000 On Jul 27, 2022, "H.J. Lu" wrote: > On Tue, Jul 26, 2022 at 10:14 PM Alexandre Oliva wrote: >> The use of @GOTOFF for locally-bound but externally-visible symbols >> (e.g. protected visibility) also breaks pointer identity if the >> canonical address ends up preempted by a PLT entry. > Here is a different fix: > https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598667.html Oh, thanks, I'd missed that. It doesn't seem to fix the part of the problem I quoted above, though. I think fixing that requires testing the visibility, to make sure the symbol's canonical address cannot be preempted, which may occur with local binding, if the symbol is protected and referenced in the main program, otherwise pointer identity is broken again, admittedly for a more obscure case, but pointer identity was the point of the PR. >> * config/i386/i386.cc (ix86_call_use_plt_p): Follow the alias >> chain looking for an ifunc, as in gcc.target/i386/mvc10.c. You may also need to do something like this bit for mvc10.c on ia32 PIE. Because the ifunc is called through an alias, AFAICT we don't even notice that the call target is (an alias to) an ifunc. GCC's gotoff_operand predicate accepts it, but binutils (the linker, IIRC) then rejects that reference, because the named symbol is an alias to an ifunc. -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about