From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 7A3C73858401 for ; Mon, 1 Aug 2022 19:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A3C73858401 Received: by mail-pj1-x1029.google.com with SMTP id p14-20020a17090a74ce00b001f4d04492faso6865190pjl.4 for ; Mon, 01 Aug 2022 12:04:57 -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=xt51wYLKsIcNl16bLiQhaKyM90WFSxN3pSQKwc8r7zE=; b=uVcwaMVRw4uZ5OGRmth5QFHGEl468b9VoIQazNaqVttGGjdqdEqkiNYCxSOh7YoNGc HePRRUN9lY2U3ABFF4/+V2Q+BAhUVBXHDo4nkm1ewJpSSHCZJd2PhyxeqS/oyl7QnY3I kdx0GjcnLDpC9BT2MAakpjcOwDTuLVcMOxAxKwO+OULzVF3ymir1X4YkxKsg+kG7MHly odi52MRZr+rZ0dILpisAjn6V0I8Vx4nmkmbahUPeWTdc0vWkLbYl8qcG/ktHOX2HDXME QvQdby1zM3xH/zbI5rAkzlqnhDphVsePABzrfPKarm7aQiW21LbVWlAbocL6SZS0LGA2 GJmQ== X-Gm-Message-State: ACgBeo01aaaR3ukiKNnBlnjSbCIr/axWDn3rraTSd7Zy/31LBozBEA4s gKBn78DSLivQhH/Fqv63kvW/ZwLP4Bv3DMPb96E= X-Google-Smtp-Source: AA6agR51eZOAp9+dU9TEfQ0rC71FTjAmqogw+9aXwcvUC4vO2njzW6D/BtRvlrj3M2s/p+r+KJhrppoOtpC49udVfNw= X-Received: by 2002:a17:902:a502:b0:15e:c251:b769 with SMTP id s2-20020a170902a50200b0015ec251b769mr18334927plq.115.1659380696264; Mon, 01 Aug 2022 12:04:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Mon, 1 Aug 2022 12:03:18 -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.6 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: Mon, 01 Aug 2022 19:04:59 -0000 On Thu, Jul 28, 2022 at 9:31 AM H.J. Lu wrote: > > 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. I think this fix should be applied to default_binds_local_p_3: if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp)) || (!targetm.ifunc_ref_local_ok () && TREE_CODE (exp) == FUNCTION_DECL && cgraph_node::get (exp) && cgraph_node::get (exp)->ifunc_resolver)) return false; since the ifunc_resolver check won't work on aliases. -- H.J.