PATCH: Handle S_ZEROFILL sections in Mach-O files correctly.

jesse michael jmichael@suse.de
Thu Aug 23 16:39:00 GMT 2007


The bfd mach-o loading code in both binutils and gdb has a bug with the
handling of S_ZEROFILL sections that results in certain non-S_ZEROFILL
sections being handled improperly.

The code in bfd_mach_o_make_bfd_section() treats BFD_MACH_O_S_ZEROFILL 
as if it were a bit flag when in reality, the section type is an 8-bit
subfield contained within the section->flags value.

There's even a comment earlier in mach-o.c pointing that out, but the
two following defines aren't used.

/* The flags field of a section structure is separated into two parts a section
   type and section attributes.  The section types are mutually exclusive (it
   can only have one type) but the section attributes are not (it may have more
   than one attribute).  */

#define SECTION_TYPE             0x000000ff     /* 256 section types.  */
#define SECTION_ATTRIBUTES       0xffffff00     /*  24 section attributes.  */

Because BFD_MACH_O_S_ZEROFILL is treated as a bit flag, any section types
with an odd value will not properly get the SEC_HAS_CONTENTS, SEC_LOAD, 
and SEC_CODE flags applied to the bfdsec struct.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-zerofill.diff
Type: text/x-patch
Size: 496 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20070823/45dfb003/attachment.bin>


More information about the Binutils mailing list