From patchwork Thu Aug 17 12:22:44 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: 802586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-83329-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="KrorSI9E"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xY52m2dqdz9t16 for ; Thu, 17 Aug 2017 22:22:55 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; q=dns; s=default; b=d4TfGxsZLb5cIy/c B+PQBYCTzrnLLCK3q0zutmAFgerVzDbvoeHhtCIhdjKRlLN+uhMQOCj/SDxx7uEq KAcq1GNGxGQp7JzXZBXI3rDUnbsJk38AzqFhPdh6+5Dq+FBhYuHl5P5Ux2AGzWP4 1ANc00DAO9y+l3Z+NE5RYTE8JZQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; s=default; bh=/0JEyYRSIaJlpa7pjnXLxP bzj4U=; b=KrorSI9EAt3pK/AQzJusICF2uGG2jZFvnHmX0yGjLc2QJJcpEm+IZa D2cM67ZlFV/BEi2qCu0D2F+PdqijwQBg5peOORPFHMj5btf66CAF1CVkMHwxQJKr 92X3iYG1l8wVmIM87I2Jaf3Sm3Yle++RMeikSekMm68Rt2QR2blq8= Received: (qmail 108805 invoked by alias); 17 Aug 2017 12:22:48 -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 108504 invoked by uid 89); 17 Aug 2017 12:22:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga14.intel.com X-ExtLoop1: 1 Date: Thu, 17 Aug 2017 05:22:44 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Add hidden visibility to internal function prototypes Message-ID: <20170817122244.GA14297@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) 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 Any comments? H.J. --- * include/libc-symbols.h (__hidden_proto_hiddenattr): New for the compiler defaulting to -fPIE. (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..6c75a6f012 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 BUILD_PIE_DEFAULT && 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__ */