[PATCH] pe/coff - add support for base64 encoded long section names
Nick Clifton
nickc@redhat.com
Wed May 17 13:30:00 GMT 2023
Hi Tristan,
> LLVM has added another convention for very large strtab, using '//xxxxxx' names and base64 encoding of the index in the strtab.
Coincidentally, this has also been reported in PR 30444...
> It has been a while since I haven't submitted a patch, I hope I am correctly following the procedure!
Oh you are. :-)
So - I have a couple of questions on the patch:
> + name = (char *) bfd_alloc (abfd, (bfd_size_type) strlen (strings) + 1 + 1);
> + if (name == NULL)
> + return NULL;
> + strcpy (name, strings);
Why "+1 +1" in the bfd_alloc ? I understand one of them, but two ?
> + unsigned strindex;
> + unsigned i;
> +
> + strindex = 0;
> + for (i = 2; i < SCNNMLEN; i++)
> + {
> + char c = hdr->s_name[i];
> + unsigned d;
> +
> + if (c >= 'A' && c <= 'Z')
> + d = c - 'A';
> + else if (c >= 'a' && c <= 'z')
> + d = c - 'a' + 26;
> + else if (c >= '0' && c <= '9')
> + d = c - '0' + 52;
> + else if (c == '+')
> + d = 62;
> + else if (c == '/')
> + d = 63;
> + else
> + return false;
> + strindex = (strindex << 6) + d;
> + }
Is "unsigned" the right type for strindex ? It seems to me that it might
be possible to encode really large numbers using base64.
Also - it might be nice to move this loop into a stand alone function so
that it can be used from other parts of the BFD library. (Assuming that
the functionality requested in PR 30444 is implemented).
Cheers
Nick
More information about the Binutils
mailing list