Fix assertion failure in the BFD library when linking with --emit-relocs enabled.
authorNick Clifton <nickc@redhat.com>
Tue, 24 Mar 2020 13:35:53 +0000 (13:35 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 24 Mar 2020 13:35:53 +0000 (13:35 +0000)
PR 25681
* elf.c (_bfd_elf_map_sections_to_segments): When looking for a
segment to use for PT_GNU_RELRO, ignore empty sections in a
segment's current list.

bfd/ChangeLog
bfd/elf.c

index 8ec3782d9ff6369caa5c539ff1c2a6ea3ba1550f..d9e1139eb1a5bba9945632aa1ffef5cf84e3b77c 100644 (file)
@@ -1,3 +1,10 @@
+2020-03-24  Nick Clifton  <nickc@redhat.com>
+
+       PR 25681
+       * elf.c (_bfd_elf_map_sections_to_segments): When looking for a
+       segment to use for PT_GNU_RELRO, ignore empty sections in a
+       segment's current list.
+
 2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR binutils/25717
index 1004809e454f179a94382d4ca17a656f497d55da..f5354d2c7a11cf62dd2679aaec14cf3d2804f2a1 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5213,9 +5213,12 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
                {
                  i = m->count;
                  while (--i != (unsigned) -1)
-                   if ((m->sections[i]->flags & (SEC_LOAD | SEC_HAS_CONTENTS))
-                       == (SEC_LOAD | SEC_HAS_CONTENTS))
-                     break;
+                   {
+                     if (m->sections[i]->size > 0
+                         && (m->sections[i]->flags & (SEC_LOAD | SEC_HAS_CONTENTS))
+                         == (SEC_LOAD | SEC_HAS_CONTENTS))
+                       break;
+                   }
 
                  if (i != (unsigned) -1)
                    break;