Stop the BFD library from complaining if a segment has no sections attached to it.
authorNick Clifton <nickc@redhat.com>
Fri, 7 Feb 2020 12:55:05 +0000 (12:55 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 7 Feb 2020 12:55:05 +0000 (12:55 +0000)
PR 23932
* elf.c (rewrite_elf_program_header): Do not complain if no
sections are mapped to a segment.

bfd/ChangeLog
bfd/elf.c

index e1a84123254cd1afeb6bb5f4eb01053dc48553ff..584dd7f3447c97c723323173d079fd859906cdb6 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-07  Nick Clifton  <nickc@redhat.com>
+
+       PR 23932
+       * elf.c (rewrite_elf_program_header): Do not complain if no
+       sections are mapped to a segment.
+
 2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/25490
index 5e6b9a0f4160c15f5e503d5d5c5e905e32b0e11b..c85face6309ffeba8f95549d297a90aa31b5375a 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7360,14 +7360,9 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
 
          /* PR 23932.  A corrupt input file may contain sections that cannot
             be assigned to any segment - because for example they have a
-            negative size - or segments that do not contain any sections.  */
-         if (map->count == 0)
-           {
-           sorry:
-             bfd_set_error (bfd_error_sorry);
-             free (sections);
-             return FALSE;
-           }
+            negative size - or segments that do not contain any sections.
+            But there are also valid reasons why a segment can be empty.
+            So allow a count of zero.  */
 
          /* Add the current segment to the list of built segments.  */
          *pointer_to_map = map;
@@ -7399,6 +7394,12 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
              map->includes_filehdr = 0;
              map->includes_phdrs = 0;
            }
+
+         continue;
+       sorry:
+         bfd_set_error (bfd_error_sorry);
+         free (sections);
+         return FALSE;
        }
       while (isec < section_count);
 
This page took 0.039551 seconds and 4 git commands to generate.