2012-01-11 Iain Sandoe <idsandoe@googlemail.com>
+ * mach-o.c (bfd_mach_o_build_seg_command): Separate computation of
+ vmsize from filesize. Don't compute offsets or file sizes for
+ zerofill sections.
+
+2012-01-11 Iain Sandoe <idsandoe@googlemail.com>
+
* mach-o.c (bfd_mach_o_build_commands): Make the building of each
command type independent.
/* TODO: fix this up for non-MH_OBJECT cases. */
seg->vmaddr = 0;
+ seg->vmsize = 0;
seg->fileoff = mdata->filelen;
seg->filesize = 0;
bfd_mach_o_append_section_to_segment (seg, sec);
- if (s->size == 0)
- s->offset = 0;
- else
+ s->offset = 0;
+ if (s->size > 0)
+ {
+ seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+ seg->vmsize += s->size;
+ }
+
+ /* Zerofill sections have zero file size & offset,
+ and are not written. */
+ if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) == BFD_MACH_O_S_ZEROFILL
+ || (s->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+ == BFD_MACH_O_S_GB_ZEROFILL)
+ continue;
+
+ if (s->size > 0)
{
mdata->filelen = FILE_ALIGN (mdata->filelen, s->align);
s->offset = mdata->filelen;
}
seg->filesize = mdata->filelen - seg->fileoff;
- seg->vmsize = seg->filesize;
return TRUE;
}