[PATCH] Exclude zero size section for RELRO segment match
Fri Feb 16 23:45:00 GMT 2018
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 <firstname.lastname@example.org> 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
> 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.
* 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
@@ -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->vma < end)
Australia Development Lab, IBM
More information about the Binutils