From: "H.J. Lu" <hjl.tools@gmail.com>
To: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] Reduce file size for PT_GNU_RELRO segment
Date: Fri, 27 Mar 2015 20:00:00 -0000 [thread overview]
Message-ID: <CAMe9rOrVpthhMfZEXcMkKzmHcxymfQHKuTuZPi_y36=s6KJ9iA@mail.gmail.com> (raw)
In-Reply-To: <20150326022246.GU26234@bubble.grove.modra.org>
On Wed, Mar 25, 2015 at 7:22 PM, Alan Modra <amodra@gmail.com> 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.
next prev parent reply other threads:[~2015-03-27 20:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 13:02 H.J. Lu
2015-03-26 2:22 ` Alan Modra
2015-03-27 20:00 ` H.J. Lu [this message]
2015-03-28 4:15 ` Alan Modra
2015-03-28 18:30 ` H.J. Lu
2015-03-28 22:46 ` H.J. Lu
2015-03-29 3:49 ` Alan Modra
2015-03-29 13:58 ` H.J. Lu
2015-03-30 12:39 ` Alan Modra
2015-03-30 13:00 ` H.J. Lu
2015-03-30 14:14 ` Alan Modra
2015-03-30 16:12 ` H.J. Lu
2015-04-01 9:12 ` Start of relro segment adjustment Alan Modra
2015-04-01 11:26 ` H.J. Lu
2015-03-29 3:19 ` [PATCH] Reduce file size for PT_GNU_RELRO segment H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOrVpthhMfZEXcMkKzmHcxymfQHKuTuZPi_y36=s6KJ9iA@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).