+ unexec_error ("cannot write section %s's header", sectp->sectname);
+ }
+ else if (strncmp (sectp->sectname, SECT_BSS, 16) == 0)
+ {
+ extern char *my_endbss_static;
+ unsigned long my_size;
+
+ sectp->flags = S_REGULAR;
+
+ /* Clear uninitialized local variables in statically linked
+ libraries. In particular, function pointers stored by
+ libSystemStub.a, which is introduced in Mac OS X 10.4 for
+ binary compatibility with respect to long double, are
+ cleared so that they will be reinitialized when the
+ dumped binary is executed on other versions of OS. */
+ my_size = (unsigned long)my_endbss_static - sectp->addr;
+ if (!(sectp->addr <= (unsigned long)my_endbss_static
+ && my_size <= sectp->size))
+ unexec_error ("my_endbss_static is not in section %s",
+ sectp->sectname);
+ if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size))
+ unexec_error ("cannot write section %s", sectp->sectname);
+ if (!unexec_write_zero (sectp->offset + my_size,
+ sectp->size - my_size))
+ unexec_error ("cannot write section %s", sectp->sectname);
+ if (!unexec_write (header_offset, sectp, sizeof (struct section)))
+ unexec_error ("cannot write section %s's header", sectp->sectname);