Now that target_section_table uses std::vector,
add_target_sections_of_objfile does not need to loop twice.  This
patch simplifies this code to have just a single loop.  Also, the
passed-in objfile can never be NULL, so this changes this function to
assert that.
gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>
	* exec.c (add_target_sections_of_objfile): Simplify.
+2020-10-12  Tom Tromey  <tom@tromey.com>
+
+       * exec.c (add_target_sections_of_objfile): Simplify.
+
 2020-10-12  Tom Tromey  <tom@tromey.com>
 
        * solib.c (solib_map_sections): Update.
 
 {
   struct target_section_table *table = current_target_sections;
   struct obj_section *osect;
-  unsigned count = 0;
 
-  if (objfile == NULL)
-    return;
+  gdb_assert (objfile != nullptr);
 
   /* Compute the number of sections to add.  */
-  ALL_OBJFILE_OSECTIONS (objfile, osect)
-    {
-      if (bfd_section_size (osect->the_bfd_section) == 0)
-       continue;
-      count++;
-    }
-
-  if (count == 0)
-    return;
-
   ALL_OBJFILE_OSECTIONS (objfile, osect)
     {
       if (bfd_section_size (osect->the_bfd_section) == 0)