diff options
author | Iain Sandoe <iain@codesourcery.com> | 2012-01-11 15:24:10 +0000 |
---|---|---|
committer | Iain Sandoe <iain@codesourcery.com> | 2012-01-11 15:24:10 +0000 |
commit | e5081f2f8f6f63affdfb386aa72184366bcc50a4 (patch) | |
tree | fa885b698ac051b0a062fbac90a004f6d3261d32 /bfd/mach-o.c | |
parent | bbd561712c8aba429cce3f8fbae663ce79997c11 (diff) | |
download | gdb-e5081f2f8f6f63affdfb386aa72184366bcc50a4.zip gdb-e5081f2f8f6f63affdfb386aa72184366bcc50a4.tar.gz gdb-e5081f2f8f6f63affdfb386aa72184366bcc50a4.tar.bz2 |
bfd:
* 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.
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r-- | bfd/mach-o.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 307a8eb..6913b1d 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -2023,6 +2023,7 @@ bfd_mach_o_build_seg_command (const char *segment, /* TODO: fix this up for non-MH_OBJECT cases. */ seg->vmaddr = 0; + seg->vmsize = 0; seg->fileoff = mdata->filelen; seg->filesize = 0; @@ -2048,9 +2049,21 @@ bfd_mach_o_build_seg_command (const char *segment, 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; @@ -2062,7 +2075,6 @@ bfd_mach_o_build_seg_command (const char *segment, } seg->filesize = mdata->filelen - seg->fileoff; - seg->vmsize = seg->filesize; return TRUE; } |