This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Exclude zero size section for RELRO segment match
- 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: Sat, 17 Feb 2018 10:14:57 +1030
- Subject: Re: [PATCH] Exclude zero size section for RELRO segment match
- Authentication-results: sourceware.org; auth=none
- References: <20180215115816.GA17271@gmail.com> <20180216120804.GI3812@bubble.grove.modra.org> <CAMe9rOq1u4v=E_6PN_=vQogWeyCeD4NpXAOsY+WbJqhrpB8xRw@mail.gmail.com>
On Fri, Feb 16, 2018 at 04:13:04AM -0800, H.J. Lu wrote:
> On Fri, Feb 16, 2018 at 4:08 AM, Alan Modra <amodra@gmail.com> wrote:
> > On Thu, Feb 15, 2018 at 03:58:16AM -0800, H.J. Lu wrote:
> >> When seaching a LOAD segment which overlaps with the RELRO segment, we
> >> need to check the size of the last non-zero size section in the LOAD
> >> segment.
> >
> > Why? Do you have a case where the current algorithm goes wrong?
> >
>
> Yes, apply this patch and I get assert in
> assign_file_positions_for_non_load_sections
> on x86-64:
On looking at the tbss1 fail, I see a PT_LOAD with a single
zero length .eh_frame section. So we have a degenerate PT_LOAD.
I think the following simpler patch is sufficient.
Your testsuite change is OK, but please check a large set of targets
before committing in case some targets won't support -z separate-code.
PR 22845
* elf.c (assign_file_positions_for_non_load_sections): Ignore
degenerate zero size PT_LOAD segments when finding one overlapping
the PT_GNU_RELRO segment.
diff --git a/bfd/elf.c b/bfd/elf.c
index 397fa62..b069b59 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5897,6 +5897,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
lm = lm->next, lp++)
{
if (lp->p_type == PT_LOAD
+ && lp->p_memsz != 0
&& lm->count != 0
&& lm->sections[lm->count - 1]->vma >= start
&& lm->sections[0]->vma < end)
--
Alan Modra
Australia Development Lab, IBM