Ignore degenerate PT_LOAD segments
authorAlan Modra <amodra@gmail.com>
Fri, 16 Feb 2018 22:51:17 +0000 (09:21 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 16 Feb 2018 23:45:55 +0000 (10:15 +1030)
Fixes a failure triggered by -z separate-code.  p_memsz is tested
rather than p_filesz for objcopy --only-keep-debug where p_filesz is
set to zero.

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.

bfd/ChangeLog
bfd/elf.c

index c314485b4236c890673dba04672a5d52a60d894d..946c6bcd7b68d949499607e60defc92ad3e866a3 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-17  Alan Modra  <amodra@gmail.com>
+
+       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.
+
 2018-02-16  Alan Modra  <amodra@gmail.com>
 
        * libbfd.c (_bfd_bool_bfd_false_error): Rename from bfd_false.
index 397fa62178f634ca5f482cab2bb26efa99e21111..b069b592652dfd4d5c82478c71ba1b67538953fa 100644 (file)
--- 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)