RFC: Objcopy: Section alignment

Nick Clifton nickc@redhat.com
Tue Mar 26 12:44:35 GMT 2024


Hi Jan,

>>    It was recently pointed out to me that objcopy's --section-alignment
>>    option does not actually set the alignment of any sections.  It just
>>    sets a field in the PE file format's optional header.  This is rather
>>    confusing for the user.
> 
> Hmm. For one --file-alignment would then want similar treatment, but
> afaict that might be more difficult to achieve (sections would need
> moving around in the file). Plus I seem to vaguely recall that there
> wants to be a certain correlation between section and file alignments
> of individual sections, which you may break with such an adjustment.

Agreed.  I think that I will leave file alignment alone for now.  If necessary
that can be the subject of a future patch.

> ... by doing this adjustment, aren't you at risk of creating overlapping
> sections? Should --set-section-alignment= perhaps be limited to
> relocatable files?

Or better yet - not done at all and just left to the user to fix...

So here is a revised patch that does not change the VMAs or LMAs to match
new section aligments, but instead issues an error message if they do not
match.  It also updates the documentation to warn users about this behaviour
and about the dangers of changing the VMAs of fully linked binaries.

Any further comments ?

Cheers
   Nick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: objcopy-section-align.patch.2
Type: application/x-troff-man
Size: 5500 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20240326/f9759e36/attachment.2>


More information about the Binutils mailing list