]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
mach-o segment section count assertion
authorAlan Modra <amodra@gmail.com>
Mon, 16 Dec 2024 07:40:10 +0000 (18:10 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 16 Dec 2024 09:07:40 +0000 (19:37 +1030)
Add an assertion that verifies we have filled the mdata->sections
array in bfd_mach_o_flatten_sections.

bfd/mach-o.c

index 9ec5cabc0210891e6cec453153f5811b6dd03ff6..8d5ca9b09a6aa9301b433fca89cc7ed6c0ee9eb0 100644 (file)
@@ -5076,7 +5076,7 @@ bfd_mach_o_flatten_sections (bfd *abfd)
 {
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
   bfd_mach_o_load_command *cmd;
-  long csect = 0;
+  unsigned long csect;
   size_t amt;
 
   /* Count total number of sections.  */
@@ -5120,6 +5120,7 @@ bfd_mach_o_flatten_sections (bfd *abfd)
            mdata->sections[csect++] = sec;
        }
     }
+  BFD_ASSERT (mdata->nsects == csect);
   return true;
 }