From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 8D0D038708DD for ; Fri, 15 Jan 2021 04:30:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8D0D038708DD Received: by mail-oi1-x232.google.com with SMTP id d203so8384815oia.0 for ; Thu, 14 Jan 2021 20:30:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F4wQYJm5tZmQftH/nlS+ZdCT0vzPrYMRyQXJ+2yCYMw=; b=RLxQwGO2mDgFp6nWfjCJc+w1V61J+P/NSypq8HMMOC4mKTvv0U87JuXC6WfKXf/Muz YPx9AnfOvk9vfAgSR2jDnWT8SUyrqkepBCpRdeDNNBYz+x5QfsSuWWYJh1eYW9AdLTF9 68TFme1xGIjSDGgJR+Acuj9Tnl+ZFkc4bCm8nIa4q7EB++MD6TOrXsSef3gXUmRH8j9I VoLXgYHun6V8E8lPbolSqJWoyuykPUglTGqLK07gNZ8qH9Xeirti5oCpt0JUY8cVfmwa +vDgp5gbt0lqUNK7YQPvpF08azSTIM+/HhD3QgSIN8AjHS6QctQmP37D1L3hjI7SxQVW SmTQ== X-Gm-Message-State: AOAM533lhLsLlq2XQ5OUNfXWOlUJRTeeBhmg/vd+qYlchSLbGkeJu2ug rR9SGtWLVOjsS8Qgn0U4emrIjdV9tTYDe4anbxI= X-Google-Smtp-Source: ABdhPJwmmElA2jweLx63aEtohAaHSoGI4PP4ZZktGHPieOFzJfuTNXAHJkD/WdPY9w6uui6l0U2DQWSBXGpFsm0F6g8= X-Received: by 2002:aca:f456:: with SMTP id s83mr4560853oih.58.1610685010330; Thu, 14 Jan 2021 20:30:10 -0800 (PST) MIME-Version: 1.0 References: <27498bbc768372541e4379794656ac2778d33035.1610471272.git.szabolcs.nagy@arm.com> <20210113095053.GA2379@arm.com> <20210114111757.GA11466@arm.com> In-Reply-To: From: "H.J. Lu" Date: Thu, 14 Jan 2021 20:29:34 -0800 Message-ID: Subject: Re: [PATCH v3 2/5] Make libc symbols hidden in static PIE To: Szabolcs Nagy Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3030.2 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 15 Jan 2021 04:30:13 -0000 On Thu, Jan 14, 2021 at 7:36 PM H.J. Lu wrote: > > On Thu, Jan 14, 2021 at 3:18 AM Szabolcs Nagy wrote: > > > > The 01/13/2021 09:50, Szabolcs Nagy via Libc-alpha wrote: > > > The 01/12/2021 17:19, H.J. Lu wrote: > > > > On Tue, Jan 12, 2021 at 4:33 PM H.J. Lu wrote: > > > > > On Tue, Jan 12, 2021 at 4:02 PM H.J. Lu wrote: > > > > > > See: > > > > > > > > > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=14961 > > > > > > > > > > > /* Mark all symbols hidden in static PIE libc to avoid GOT indirections. */ > > > > > -#if BUILD_PIE_DEFAULT && IS_IN (libc) && !defined LIBC_NONSHARED > > > > > +#if BUILD_PIE_DEFAULT && !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE \ > > > > > + && IS_IN (libc) && !defined LIBC_NONSHARED > > > > > # pragma GCC visibility push(hidden) > > > > > #endif > > > > > > > > > > > > > This works on i686. > > > > The series i plan to commit today is in nsz/bug27072 now, > > > > This is the v4 of this patch: > > > > Hidden matters with static PIE: extern symbol access in position > > independent code usually involves GOT indirections which needs > > RELATIVE relocs in a static linked PIE. Hidden visibility avoids > > indirections and RELATIVE relocs on targets that can access symbols > > pc-relative. > > > > The check should use IS_IN_LIB instead of IS_IN(libc) since all > > static libraries can use hidden visibility to avoid indirections, > > however the test system links objects from libcrypt.a into dynamic > > linked test binaries so hidden does not work there. I think mixing > > static and shared libc components in the same binary should not be > > supported usage, but to be safe only use hidden in libc.a. > > > > There are targets (i686) where hidden visibility functions are > > problematic in PIE code so hidden cannot be applied to all symbols. > > Then static PIE requires extern object access without relocations > > (e.g. by relying on copy relocations in shared libraries instead of > > GOT access in PIE code). See bug 14961. > > It isn't about copy relocations. It is IFUNC, PLT and PIE. I needed > additional patches to make static PIE to work on i386 and x86-64. > I am enclosing my patches. Please include them in your patch set. > > > From -static-pie linked 'int main(){}' this shaves off 73 relative > > relocs on aarch64 and reduces code size too. > > > -- > H.J. commit c5ffa46591550d945b009f0e3bcf66603d48ac0b Author: H.J. Lu Date: Thu Jan 14 13:26:29 2021 -0800 i386: Call _dl_aux_init after relocating static PIE is too complicated. I will submit a simple version. -- H.J.