From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 14AAC3858402 for ; Sat, 19 Feb 2022 00:49:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14AAC3858402 Received: by mail-pl1-x62a.google.com with SMTP id w20so8391640plq.12 for ; Fri, 18 Feb 2022 16:49:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=t06y2+QRKr9Kzk7kISIafupQiXS+GzjrUyD5JS0QapA=; b=ZZtt+l/g8CXENww0ry2qVClQusvPdHnQ04Xj9HE62D1++6tBnULRSttQoGpd4auSZx F+zsgIKlxmZBni6EQgxdSESDo46hRMZPRTrvnHjpkKmZSaXr/y8R5umy9dTvBw+NHf07 jMbWGPOS2KRHwZcYYV2dUBR8UBgFx5Oho5pgcDk+ismCMvUnQt5+wspLKXDQwpM/u5Vh bb3JEFY4VLCGUJmCZ6MQ3e8VHVfBB5aI12zL+YbT1I9LO8GNPx0wKNmfJc90c7bwvpYY zk7LnlXBkFt6//QT7m9DGyPH3ISj+rqkEhPnreztaaC9KBCWKT/9Ib5/ydTSD3dy/4rL rIkQ== X-Gm-Message-State: AOAM533ML4MQ4m3FEFra1ywz1CeO1eWCTPs93b5JMDA+SIZfidv8awrY Uiz7NrMEyZKYpyH+GFPxM6A= X-Google-Smtp-Source: ABdhPJzt000jlWn29F1xi7DCs3k3zwGoSejqaGH2UHYW3DYW30LcJlL2VKD0GyEYPdUSmQ8CJSBiaw== X-Received: by 2002:a17:90a:ac0e:b0:1b8:7c57:b5e6 with SMTP id o14-20020a17090aac0e00b001b87c57b5e6mr10732170pjq.166.1645231756887; Fri, 18 Feb 2022 16:49:16 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id z14sm4607842pfh.173.2022.02.18.16.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 16:49:16 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id B0ED811412BA; Sat, 19 Feb 2022 11:19:12 +1030 (ACDT) Date: Sat, 19 Feb 2022 11:19:12 +1030 From: Alan Modra To: Paul E Murphy Cc: libc-alpha@sourceware.org, Tulio Magno Quites Machado Filho Subject: Re: [PATCH 2/5] [PowerPC64] Set up thread register for _dl_relocate_static_pie Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3031.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2022 00:49:20 -0000 On Wed, Feb 16, 2022 at 05:02:51PM -0600, Paul E Murphy wrote: > > > On 1/23/22 9:47 PM, Alan Modra via Libc-alpha wrote: > > On Sun, Jan 23, 2022 at 11:12:13PM +1030, Alan Modra wrote: > > > There's a serious problem in libgcc too. libgcc ifuncs access the > > > AT_HWCAP words stored in the tcb with an offset from the thread > > > pointer (r13), but r13 isn't set at the time _dl_relocate_static_pie > > > runs, and I'm loathe to try calling init_tls early. A better approach > > > that might work is to fake r13 so that _dl_hwcap is at the expected > > > offset where we'd normally find the tcb hwcap words. > > > > Like this. > > > > libgcc ifunc resolvers that access hwcap via a field in the tcb can't > > be called until the thread pointer is set up. This patch sets up a > > fake thread pointer early so that static-pies won't segfault on > > attempting to relocate themselves. > > > > I suspect the thread pointer needs to be setup more. How much, I am not > sure. > > Looking into the failure of tst-tlsifunc-static, we would need similar > access to at_platform when resolving ifunc for similar reasons of hwcap. > That seems like an easy fix. Yes, it means arranging to have a copy of at_platform accessible from the fake tls pointer reg, not just __tcb_hwcap. A tcbhead_t in sysdeps/powerpc/hwcapinfo.c replacing __tcb_hwcap and __tcb_platform there would be best, I think. > However, I am not sure what to make of the other failure in this test. A > pointer into tls is created as part of running an ifunc resolver. Do we > need to preserve that behavior? Tulio will be better placed to answer this question. Note that a number of glibc test failures disappear with binutils commit 3a3a4c1fe4c. -- Alan Modra Australia Development Lab, IBM