PE known sections having certain flags enforced

Nick Clifton nickc@redhat.com
Mon Oct 9 13:04:00 GMT 2017


Hi Jan,

> back in 2003 you've changed bfd/peXXigen.c's
> _bfd_XXi_swap_scnhdr_out() to force certain flags for known
> sections. Considering the function this lives in, the change appears
> to make it impossible to create binaries with flags varying from the
> ones being enforced there, as even objcopy would come through
> that path.

Right - I think that this is a requirement of the PE format specification,
which is why it is being enforced here.  See the "Special Sections" entry
in the "Microsoft Portable Executable and Common Object File Format Specification"
document for more details.


> we've found a need to produce .reloc sections without the
> discardable flag set,

> Do you have any suggestion how to achieve this without creating
> a custom tool to effect the change, and also without renaming the
> section (since, as sad as it is, it's likely not just binutils to imply
> section purpose from section name)?

Hmm, well the only solution I can think of would be to enhance the --set-section-flags
option of objcopy so that it could be used on PE binaries as well.  This
would be a bit of a hack though, as we would need to create a way to tell
swap_scnhdr_out() that it should not override the flags that have been set.

Patches welcome... :-)

Cheers
  Nick




More information about the Binutils mailing list