[PATCH v2] pe/coff - add support for base64 encoded long section names

Jose E. Marchesi jose.marchesi@oracle.com
Tue May 23 09:17:50 GMT 2023


Hello Tristan.

> so new version of the patch, including generation of base64 encoded
> section name indexes.
>
> I was able to assemble the test from PR 30444 (using -mbig-obj to
> overcome the 2^16 sections number limit).

Very nice.  I wasn't aware of -mbig-ob.

> +#ifdef COFF_WITH_PE
> +		{
> +		  /* PE use a bae64 encoding for long section names whose
> +		     index is very large.  */

I would suggest to add a note to that comment making it explicit that
this encoding is not RFC 4648, even if it happens to use the same
alphabet.  Spelling this as `base 64' rather than 'base64' may help to
avoid confusion.

> +		  static const char base64[] =
> +		    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> +		    "abcdefghijklmnopqrstuvwxyz"
> +		    "0123456789+/";
> +		  unsigned long off = string_size;
> +		  unsigned i;
> +
> +		  section.s_name[0] = '/';
> +		  section.s_name[1] = '/';
> +		  for (i = SCNNMLEN - 1; i >=2; i--)
> +		    {
> +		      section.s_name[i] = base64[off & 0x3f];
> +		      off >>= 6;
> +		    }
> +		}
> +#endif
> +	      if (string_size > 0xffffffffUL - (len + 1)
> +#ifndef COFF_WITH_PE
> +		  || string_size >= 10000000
> +#endif
> +		  )
>  		{


More information about the Binutils mailing list