From: Alan Modra <amodra@gmail.com>
To: Zac Walker <zac.walker@linaro.org>
Cc: Nick Clifton <nickc@redhat.com>, binutils@sourceware.org
Subject: aarch64-pe can't fill 16 bytes in section .text
Date: Wed, 16 Nov 2022 08:23:23 +1030 [thread overview]
Message-ID: <Y3QKUwDn748CbDIs@squeak.grove.modra.org> (raw)
In-Reply-To: <584ecd9c-7876-8e2f-4610-8b51cab366b8@linaro.org>
I'm going to fix the underlying coff_frob_section problem too.
Without commit b66e671854, this:
.p2align 4
nop
.p2align 3
nop
results in an error when coff_frob_section attempts to pad out the
section to a 16-byte boundary. Due to miscalculating the pad pattern
repeat count, write.c:write_contents attempts to shove 16 bytes of
padding into the remaining 4 bytes of the .text section.
* config/obj-coff.c (coff_frob_section): Correct fill count.
Don't pad after errors.
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 98c39e43907..9be697fb62e 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -1725,7 +1725,8 @@ coff_frob_section (segT sec)
bfd_vma align_power = (bfd_vma) sec->alignment_power + OCTETS_PER_BYTE_POWER;
bfd_vma mask = ((bfd_vma) 1 << align_power) - 1;
- if (size & mask)
+ if (!do_not_pad_sections_to_alignment
+ && (size & mask) != 0)
{
bfd_vma new_size;
fragS *last;
@@ -1740,7 +1741,10 @@ coff_frob_section (segT sec)
while (fragp->fr_next != last)
fragp = fragp->fr_next;
last->fr_address = size;
- fragp->fr_offset += new_size - size;
+ if ((new_size - size) % fragp->fr_var == 0)
+ fragp->fr_offset += (new_size - size) / fragp->fr_var;
+ else
+ abort ();
}
#endif
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2022-11-15 21:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 17:24 [PATCH V2] GAS fix alignment for aarch64-pe Zac Walker
2022-11-15 10:50 ` Nick Clifton
2022-11-15 11:23 ` Zac Walker
2022-11-15 21:53 ` Alan Modra [this message]
2022-11-16 17:03 ` aarch64-pe can't fill 16 bytes in section .text Zac Walker
2022-11-17 3:01 ` Alan Modra
2022-11-18 8:52 ` zac.walker
2022-11-18 9:08 ` Jan Beulich
2022-11-18 9:35 ` zac.walker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3QKUwDn748CbDIs@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=nickc@redhat.com \
--cc=zac.walker@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).