This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Reduce file size for PT_GNU_RELRO segment
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 29 Mar 2015 14:18:58 +1030
- Subject: Re: [PATCH] Reduce file size for PT_GNU_RELRO segment
- Authentication-results: sourceware.org; auth=none
- References: <20150319130244 dot GA22592 at intel dot com> <20150326022246 dot GU26234 at bubble dot grove dot modra dot org> <CAMe9rOrVpthhMfZEXcMkKzmHcxymfQHKuTuZPi_y36=s6KJ9iA at mail dot gmail dot com> <20150328041540 dot GE26234 at bubble dot grove dot modra dot org> <CAMe9rOoVzbOvdE1_apgUbHtm0gG89d3_9qbnA8=Y3Qu9MznUPA at mail dot gmail dot com> <CAMe9rOp8sdCbOp0eVzRmwMhe_3c2K0EJ6fmnMMWyA01KYamzLw at mail dot gmail dot com>
On Sat, Mar 28, 2015 at 03:46:49PM -0700, H.J. Lu wrote:
> On Sat, Mar 28, 2015 at 11:30 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Fri, Mar 27, 2015 at 9:15 PM, Alan Modra <amodra@gmail.com> wrote:
> >> On Fri, Mar 27, 2015 at 01:00:20PM -0700, H.J. Lu wrote:
> >>> On Wed, Mar 25, 2015 at 7:22 PM, Alan Modra <amodra@gmail.com> wrote:
> >>> > 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?
> >>>
> >>> segment. In order to properly align PT_GNU_RELRO segmnet, we pad the first
> >>> section of PT_GNU_RELRO segment by
> >>
> >> Adjusting the start of the first section of the PT_GNU_RELRO segment
> >> is exactly what DATA_SEGMENT_ALIGN is supposed to do. You are
> >> patching the wrong place. Any adjustment to the start of the relro
> >> segment belongs in ldexp.c code evaluating DATA_SEGMENT_ALIGN.
> >
> > Since output_section_statement isn't passed to ldexp.c, I don't see how
> > DATA_SEGMENT_ALIGN in ldexp.c can check the section address and size.
>
> lang_size_sections aligns expld.dataseg.base:
You're correct. I thought I knew this code well enough to review your
patch without looking at the existing code. Obviously not.
Howver, I'm glad you also had to look at the entirety of the relro
code as that should make you realize that the patch you posted isn't
very elegant. For instance, there is no need for
output_prev_load_sec_find since the end of the previous section is
available in expld.dataseg.min_base. Also, the bulk of the patch
still belongs with the other relro code handling DATA_SEGMENT_ALIGN
(not in ldexp.c as I wrongly claimed before, but in
lang_size_sections). I think it important that we keep the relro base
alignment code all in one place.
--
Alan Modra
Australia Development Lab, IBM