[binutils-gdb] vms-alpha store immediate repeated
Alan Modra
amodra@sourceware.org
Tue Jan 20 23:40:20 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d9a8dcf48b98e103670b3a6357830a2a557eb2a2
commit d9a8dcf48b98e103670b3a6357830a2a557eb2a2
Author: Alan Modra <amodra@gmail.com>
Date: Tue Jan 20 20:37:44 2026 +1030
vms-alpha store immediate repeated
Speed up parsing of fuzzed object with ridiculous repeat counts,
particularly when the object will later fail alpha_vms_object_p for
some reason.
* vms-alpha.c (image_write_section): New function, extracted..
(image_write): ..from here.
(_bfd_vms_slurp_etir <ETIR__C_STO_IMMR>): Optimise sizing.
Diff:
---
bfd/vms-alpha.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index e4e5b4553c4..eea3c95dab8 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -1598,18 +1598,24 @@ dst_retrieve_location (bfd *abfd, bfd_vma *loc)
return false;
}
+static asection *
+image_write_section (bfd *abfd)
+{
+ asection *sec = PRIV (image_section);
+
+ if ((sec->flags & SEC_IN_MEMORY) != 0 && sec->contents == NULL)
+ return NULL;
+ return sec;
+}
+
/* Write multiple bytes to section image. */
static bool
-image_write (bfd *abfd, unsigned char *ptr, unsigned int size)
+image_write (bfd *abfd, unsigned char *ptr, size_t size)
{
- asection *sec = PRIV (image_section);
+ asection *sec = image_write_section (abfd);
- if ((sec->flags & SEC_IN_MEMORY) != 0
- && sec->contents == NULL)
- /* Not yet allocated. Just increment size. */
- ;
- else
+ if (sec)
{
size_t off = PRIV (image_offset);
/* Check bounds. */
@@ -2081,7 +2087,7 @@ _bfd_vms_slurp_etir (bfd *abfd, struct bfd_link_info *info)
da data. */
case ETIR__C_STO_IMMR:
{
- unsigned int size;
+ size_t size;
if (cmd_length < 4)
goto corrupt_etir;
@@ -2095,6 +2101,12 @@ _bfd_vms_slurp_etir (bfd *abfd, struct bfd_link_info *info)
if (size == 0)
break;
op1 &= 0xffffffff;
+ if (!image_write_section (abfd))
+ {
+ /* We are just sizing. Optimise a little. */
+ size *= op1;
+ op1 = 1;
+ }
while (op1-- > 0)
if (!image_write (abfd, ptr + 4, size))
return false;
More information about the Binutils-cvs
mailing list