From patchwork Thu Aug 17 18:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 22194 Received: (qmail 113433 invoked by alias); 17 Aug 2017 18:25:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 110401 invoked by uid 89); 17 Aug 2017 18:25:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=blz+pUOAHDCOtKlvVCXenXtVuIww0PC8AguINkQo6is=; b=BPD2DjJf3Vfb4cmIVZ+nzNh032jTbxr5SdkJxeRw+x0tI5l2n6rxr0sdxKqsdRGj41 29S8l9OaJPoBjQLG3L+F6rFXx5uYhzRfE9IdKjbXpkWA3w89xzITP/2VoBSbpG3E5SNq Lomrc25yeZfeOrQlYCXLKn7pyoMvumJodv1Mv7aBO2MiyRvy37QKU3LTOf9JZix7af4Y KnyicZrfMdsxc2i+Q9ccr8ej0dAcQ5NIOQMpkN6CgUNSTfsCmldyt9SY+M+B30P9kpgi VIMIvuVxSZmc9IBYOVOWuNXT7O9w9kuMA8qcqbjVKsmUTNSP7BVL/tI+7CbVOPjqeESm 7bxw== X-Gm-Message-State: AHYfb5jKtAVAjkk4t+2LjTG0+HGPxJZE3mf7T1aE1kWarOiyNWzbzIW7 hRk7u7RNdCB70b59uDn6KmpMYFb2IQ== X-Received: by 10.55.108.131 with SMTP id h125mr8139440qkc.285.1502994323795; Thu, 17 Aug 2017 11:25:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20170817122244.GA14297@gmail.com> <1cb1b2db-db57-85dd-02ff-a7a1371bcee3@redhat.com> From: "H.J. Lu" Date: Thu, 17 Aug 2017 11:25:23 -0700 Message-ID: Subject: Re: [PATCH] Add hidden visibility to internal function prototypes To: Florian Weimer Cc: GNU C Library On Thu, Aug 17, 2017 at 5:40 AM, H.J. Lu wrote: > On Thu, Aug 17, 2017 at 5:34 AM, Florian Weimer wrote: >> On 08/17/2017 02:22 PM, H.J. Lu wrote: >>> Add hidden visibility to internal function prototypes to allow direct >>> access to internal functions within libc.a without using GOT when the >>> compiler defaults to -fPIE. >>> >>> Size comparison of elf/ldconfig when the compiler defaults to -fPIE: >> >> This is for static linking, right? >> >> Is there a reason to restrict this to PIE builds? Why not use hidden >> visibility unconditionally? >> > > Yes, there is only used for static PIE build and we can replace > BUILD_PIE_DEFAULT with !defined SHARED. But it makes > no difference for non-PIE static build. > Here is the updated patch to add hidden visibility to internal function prototypes used within libc.a. Tested on x86-64 and i686 with and without GCC defaulting to PIE. OK for master? From 236f3b88f74d408d3ab925809da3bd6d8a995730 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 13 Aug 2017 07:37:34 -0700 Subject: [PATCH] Add hidden visibility to internal function prototypes Add hidden visibility to internal function prototypes to allow direct access to internal functions within libc.a without using GOT when the compiler defaults to -fPIE. Size comparison of elf/ldconfig when the compiler defaults to -fPIE: On x86-64: text data bss dec hex Before: 619646 20132 5488 645266 9d892 After : 619502 20132 5488 645122 9d802 On i686: text data bss dec hex Before: 550333 10748 3060 564141 89bad After : 546453 10732 3060 560245 88c75 * include/libc-symbols.h (__hidden_proto_hiddenattr): New for building libc.a. (hidden_proto): Likewise. (hidden_tls_proto): Likewise. (__hidden_proto): Likewise. --- include/libc-symbols.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index d6a1c260f6..fe3571af52 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -513,8 +513,20 @@ for linking") # endif #else # ifndef __ASSEMBLER__ -# define hidden_proto(name, attrs...) -# define hidden_tls_proto(name, attrs...) +# if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \ + && !defined NO_HIDDEN +# define __hidden_proto_hiddenattr(attrs...) \ + __attribute__ ((visibility ("hidden"), ##attrs)) +# define hidden_proto(name, attrs...) \ + __hidden_proto (name, , name, ##attrs) +# define hidden_tls_proto(name, attrs...) \ + __hidden_proto (name, __thread, name, ##attrs) +# define __hidden_proto(name, thread, internal, attrs...) \ + extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs); +# else +# define hidden_proto(name, attrs...) +# define hidden_tls_proto(name, attrs...) +# endif # else # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name) # endif /* Not __ASSEMBLER__ */ -- 2.13.5