From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34775 invoked by alias); 27 Mar 2015 20:00:24 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 33982 invoked by uid 89); 27 Mar 2015 20:00:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.7 required=5.0 tests=AWL,BAYES_40,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f173.google.com Received: from mail-ob0-f173.google.com (HELO mail-ob0-f173.google.com) (209.85.214.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Mar 2015 20:00:22 +0000 Received: by obbgh1 with SMTP id gh1so17321375obb.1 for ; Fri, 27 Mar 2015 13:00:20 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.191.194 with SMTP id p185mr16717186oif.128.1427486420788; Fri, 27 Mar 2015 13:00:20 -0700 (PDT) Received: by 10.76.134.102 with HTTP; Fri, 27 Mar 2015 13:00:20 -0700 (PDT) In-Reply-To: <20150326022246.GU26234@bubble.grove.modra.org> References: <20150319130244.GA22592@intel.com> <20150326022246.GU26234@bubble.grove.modra.org> Date: Fri, 27 Mar 2015 20:00:00 -0000 Message-ID: Subject: Re: [PATCH] Reduce file size for PT_GNU_RELRO segment From: "H.J. Lu" To: Binutils Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00407.txt.bz2 On Wed, Mar 25, 2015 at 7:22 PM, Alan Modra wrote: > On Thu, Mar 19, 2015 at 06:02:44AM -0700, H.J. Lu wrote: >> When a padding in file is used to align PT_GNU_RELRO segment, the maximum >> padding size is maximum page size minus 1. This patch trades memory size >> for file size by increasing memory size to avoid padding if file size >> will be reduced by more than maximum page minus a page and memory size >> will be increased by less than a page. > > Isn't this just re-inventing the commonpage adjustment done for > DATA_SEGMENT_ALIGN? Why didn't the existing code in ldexp.c work for > you? The existing code in ldexp.c only deals with sections within PT_GNU_RELRO segment. It doesn't consider impact of the section just before PT_GNU_RELRO segment on the file size due to the alignment requirement for PT_GNU_RELRO segment. In order to properly align PT_GNU_RELRO segment, we pad the first section of PT_GNU_RELRO segment by ((sec->vma - (prev_sec->vma + prev_sec->size)) % common_pagesize If we can reduce the padding significantly by increasing the address of the first section of PT_GNU_RELRO segment just a little bit, we limit the padding to the minimum and generate a much smaller binary. That is what my patch does. -- H.J.