From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 9F1D53858D33 for ; Thu, 28 Jul 2022 16:32:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F1D53858D33 Received: by mail-pl1-x636.google.com with SMTP id d3so2245864pls.4 for ; Thu, 28 Jul 2022 09:32:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NwXvEyG2zxGA8nYT4vIp59ViSbdYMr34dJJm8T4cVoY=; b=xe/hk3QR/H8x92DxCCgmzS2yL1zm2nNT5mg+M+4AX0srVkjE6J8mn6xXRJccU/KKoa 8mBS3QOaaqa2lvA6OFIKqAxvCBlSL/aHYpz3RINYGeVitClRAya9OmkY2tzVES6h0yI2 hj8ZlrLI9NjtuX1xRr4vhSayBJGe312RUelWPKrBenhVZUFFQjjZTEHAd7AQSaThYTTX 28p3zcNAeQHMcHpHYmNMBQ3OoImxDPQEf6MxVzkEpe8Sr8CjFASTga+3hqWVc2ettnwI GauGSTUM2tojIjV7brH+pYlvZG6ttpNQAbkXETYeOfCeJI4z+xSygsHTC/1murcUFiAc 4iVQ== X-Gm-Message-State: ACgBeo0+ivskTaWn5NlH94X00YmlFF23tGzp3prhdiuMT5PEttf6oaVB d1H7bYZrF/o/bPmlp3+zqzQyhFNeScj/qnm2CdA= X-Google-Smtp-Source: AA6agR7gLOFHiWnaV1VZFGZFCBkBO6BNDOp4TmHV42gCWkaRUOdzPtnIj6EMHYzyXWLahAYHRZEuymCIMq/a8dIrsV0= X-Received: by 2002:a17:90b:3ec3:b0:1f1:ff45:1d3b with SMTP id rm3-20020a17090b3ec300b001f1ff451d3bmr199564pjb.101.1659025923397; Thu, 28 Jul 2022 09:32:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Thu, 28 Jul 2022 09:31:27 -0700 Message-ID: Subject: Re: [PATCH] [PR83782] i386 PIE: avoid @GOTOFF for ifuncs and their aliases To: Alexandre Oliva Cc: GCC Patches , Jan Hubicka , Uros Bizjak Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3018.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 16:32:07 -0000 On Thu, Jul 28, 2022 at 1:26 AM Alexandre Oliva wrote: > > 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. The protected symbol issue isn't IFUNC specific. The protected symbol handling is changed in glibc 2.36 and binutils 2.39. Only the address of the protected symbol definition should be used as its address. > >> * 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. Yes, this change is needed. > > -- > 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 -- H.J.