aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-11-15 18:43:43 +1030
committerAlan Modra <amodra@gmail.com>2022-11-16 07:51:24 +1030
commitbc8f3910c08212b325fda273f01566da8f53c81a (patch)
treef84ca5534b4d305b138fcdd785a518bf079e843c /gas
parent02dbc2b9e76ad0cd452563c3ee7a8b1571eed89b (diff)
downloadgdb-bc8f3910c08212b325fda273f01566da8f53c81a.zip
gdb-bc8f3910c08212b325fda273f01566da8f53c81a.tar.gz
gdb-bc8f3910c08212b325fda273f01566da8f53c81a.tar.bz2
aarch64-pe can't fill 16 bytes in section .text
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.
Diffstat (limited to 'gas')
-rw-r--r--gas/config/obj-coff.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 98c39e4..9be697f 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