- /* Set up the minimum segment alignment */
- if (Sec->Align > S->Align) {
- /* Section needs larger alignment, use this one */
- S->Align = Sec->Align;
- S->AlignObj = O;
+ /* Set up the combined segment alignment */
+ if (Sec->Alignment > 1) {
+ Alignment = LeastCommonMultiple (S->Alignment, Sec->Alignment);
+ if (Alignment > MAX_ALIGNMENT) {
+ Error ("Combined alignment for segment `%s' is %lu which exceeds "
+ "%lu. Last module requiring alignment was `%s'.",
+ GetString (Name), Alignment, MAX_ALIGNMENT,
+ GetObjFileName (O));
+ } else if (Alignment >= LARGE_ALIGNMENT) {
+ Warning ("Combined alignment for segment `%s' is suspiciously "
+ "large (%lu). Last module requiring alignment was `%s'.",
+ GetString (Name), Alignment, GetObjFileName (O));
+ }
+ S->Alignment = Alignment;