+2020-05-04  Fangrui Song   <maskray@google.com>
+
+       * objcopy.c (copy_object): Allow empty section.
+       * testsuite/binutils-all/update-section.exp: Add test.
+
 2020-05-04  Nick Clifton  <nickc@redhat.com>
 
        PR 25917
 
 
       for (pdump = dump_sections; pdump != NULL; pdump = pdump->next)
        {
+         FILE * f;
+         bfd_byte *contents;
+
          osec = bfd_get_section_by_name (ibfd, pdump->name);
          if (osec == NULL)
            {
            }
 
          bfd_size_type size = bfd_section_size (osec);
-         if (size == 0)
-           {
-             bfd_nonfatal_message (NULL, ibfd, osec,
-                                   _("can't dump section - it is empty"));
-             continue;
-           }
+         /* Note - we allow the dumping of zero-sized sections.  */
 
-         FILE * f;
          f = fopen (pdump->filename, FOPEN_WB);
          if (f == NULL)
            {
              continue;
            }
 
-         bfd_byte *contents;
          if (bfd_malloc_and_get_section (ibfd, osec, &contents))
            {
              if (fwrite (contents, 1, size, f) != size)
 
     }
 }
 
+# Check that we can dump empty sections.
+if { ![do_objcopy update-1.o "--dump-section .text=tmpdir/empty"] } {
+    fail "objcopy (dump empty section)"
+} else {
+    pass "objcopy (dump empty section)"
+}
+
 if { ![do_objcopy update-1.o \
            "--dump-section .foo=tmpdir/dumped-contents"]
      || ![do_objcopy update-2.o \