From patchwork Tue Aug 8 16:40:40 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: 799339 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-82869-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="K5VKY/hs"; 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 3xRgBY6Dq7z9s5L for ; Wed, 9 Aug 2017 02:40:53 +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=wv2axltG/76t/YOZ MrlU1CFGRsiz0rz6htqDoXqrTD2CFatGKidpkyQk8g6q2o9zaOKpjChItmSncDa6 4fQQ/kxoi+1giTrXSCVv4JWMK8XOo+eUujQ5uwohaB8DM5t5+2MSn6CJP22Ld7VS pDU61N0cgzDy4NeQM+mihr93ykM= 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=I2FkUiQL9WxMC8I6kkUE0/ uHGpY=; b=K5VKY/hsoxAFaEnGZQup2LIRjDXveHjmEbcB5MMfi9hvuWo+uDqD4b IdC6WlRwE1WlVu2Sim/MwWVfJG6jT4B553VbiXZEe9vvLW5gxe9z/h5o6sC9vf7q ZENmrS1ofm/POoXbXxwLFoNYME+a0djpxBAzjPfoqanzjqEYA0jeI= Received: (qmail 43118 invoked by alias); 8 Aug 2017 16:40:44 -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 42025 invoked by uid 89); 8 Aug 2017 16:40:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 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: mga04.intel.com X-ExtLoop1: 1 Date: Tue, 8 Aug 2017 09:40:40 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Enable hidden visibility in libc.a compiled with PIE Message-ID: <20170808164040.GA31184@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) When building libc.a with PIE, enable hidden visibility to allow direct access to definitions within libc.a without using GOT. Size comparison of elf/ldconfig when the compiler defaults to -fPIE: On x86-64: text data bss dec hex Before: 619206 20132 5488 644826 9d6da After : 619062 20132 5488 644682 9d64a On i686: text data bss dec hex Before: 556305 10816 3056 570177 8b341 After : 553688 10756 3056 567500 8a8cc OK for master? H.J. --- * include/libc-symbols.h (attribute_hidden): Enable hidden visibility in libc.a compiled with PIE. --- include/libc-symbols.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index fe3ab81c51..d6a1c260f6 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -363,7 +363,8 @@ for linking") strong_alias(real, name) #endif -#if defined SHARED || defined LIBC_NONSHARED +#if defined SHARED || defined LIBC_NONSHARED \ + || (BUILD_PIE_DEFAULT && IS_IN (libc)) # define attribute_hidden __attribute__ ((visibility ("hidden"))) #else # define attribute_hidden