[binutils-gdb] mach-o segment section count assertion

Alan Modra amodra@sourceware.org
Mon Dec 16 10:59:29 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bc7b21018e0721de7eefec04a11ff7f82dce1e82

commit bc7b21018e0721de7eefec04a11ff7f82dce1e82
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Dec 16 18:10:10 2024 +1030

    mach-o segment section count assertion
    
    Add an assertion that verifies we have filled the mdata->sections
    array in bfd_mach_o_flatten_sections.

Diff:
---
 bfd/mach-o.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 9ec5cabc021..8d5ca9b09a6 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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;
 }


More information about the Binutils-cvs mailing list