[ld] section address : ALIGN(align) and the maximum of input section alignments
Alan Modra
amodra@gmail.com
Wed Mar 4 08:04:00 GMT 2020
On Tue, Mar 03, 2020 at 10:39:45PM -0800, Fangrui Song wrote:
> The implementation is complex. For users to understand, I think it
> will be helpful to have something more detailed in
> https://sourceware.org/binutils/docs/ld/Output-Section-Address.html#Output-Section-Address
>
> If my understanding is correct
> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=233bf4f847b136705247e2f7f11bae41c72448a4
> makes the output section address override sh_addralign computed from
> the maximum of input section alignments.
Right.
> So, generally the rules are:
> * The max of ALIGN and (the maximum of input section alignments) is taken.
> * The output section address overrides the above. If sh_addr %
> alignment != 0, set sh_addralign to the largest alignment that makes
> sh_addr%alignment=0
> In this case, should the linker emit a warning?
I don't think so. The input sections are still aligned within the
output section to their required alignment.
> * ALIGN and the output section address cannot be specified at the same
> time. This is considered a linker script "undefined behavior". Users
> should not rely on a particular result.
I'm not going to make that change for ld.bfd. I said it probably
would have been better if ALIGN for output section statements hadn't
been invented, but once there are users for a script feature it can't
be removed without a good reason.
> --warn-section-align may be out of place. It can be noisy for normal
> output section descriptions like .foo : ALIGN(16) { ... } without
> a preceding dot advancing to a multiple of 16.
It's even more noisy when relaxation is enabled..
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list