For the aarch64-pe target, section alignment for various values of '.align' causes writing of coff files to fail. This patch performs aligning in md_section_align as opposed to the original approach in aarch64_handle_align. The change is specific to the aarch64-pe target. Thanks, Zac --- gas/config/tc-aarch64.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index f6fa158583..44ad510209 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -8290,13 +8290,22 @@ md_estimate_size_before_relax (fragS * fragp, segT segtype ATTRIBUTE_UNUSED) return 4; } -/* Round up a section size to the appropriate boundary. */ - +/* Round up a COFF section size not needed for ELF */ +#ifdef OBJ_COFF +valueT +md_section_align (segT segment, valueT size) +{ + int align = bfd_section_alignment (segment); + valueT mask = ((valueT) 1 << align) - 1; + return (size + mask) & ~mask; +} +#else /* !OBJ_COFF */ valueT md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) { return size; } +#endif /* !OBJ_COFF */ /* This is called from HANDLE_ALIGN in write.c. Fill in the contents of an rs_align_code fragment. @@ -8353,7 +8362,11 @@ aarch64_handle_align (fragS * fragP) if (noop_size) memcpy (p, aarch64_noop, noop_size); + +/* COFF sections may have unaligned fr_var and then be aligned in md_section_align */ +#ifndef OBJ_COFF fragP->fr_var = noop_size; +#endif } /* Perform target specific initialisation of a frag. -- 2.25.1