[PATCH 2/3] move read-only delayimp data into .rdata

Jeremy Drake sourceware-bugzilla@jdrake.com
Fri May 2 17:03:31 GMT 2025


On Fri, 2 May 2025, Jan Beulich wrote:

> On 15.04.2025 07:08, Jeremy Drake wrote:
> > Date: Sat, 8 Mar 2025 13:03:43 -0800
> >
> > This allows the delay IAT to be in its own section with nothing else, as
> > required by IMAGE_GUARD_DELAYLOAD_IAT_IN_ITS_OWN_SECTION, documented at
> > https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#load-configuration-layout
> >
> > Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
> > ---
> >  binutils/dlltool.c    | 26 ++++++++++++++------------
> >  ld/scripttempl/pe.sc  | 13 ++++++++-----
> >  ld/scripttempl/pep.sc | 14 +++++++++-----
> >  3 files changed, 31 insertions(+), 22 deletions(-)
>
> Looks largely plausible, and I would approve it as is, if there weren't ...
>
> > @@ -2827,26 +2827,28 @@ make_delay_head (void)
> >    if (!no_idata5)
> >      {
> >        fprintf (f, "\t.section\t.didat$5\n");
> > -      /* NULL terminating list.  */
> > -      if (create_for_pep)
> > -	fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG);
> > -      else
> > -	fprintf (f, "\t%s\t0\n", ASM_LONG);
> > +      if (use_nul_prefixed_import_tables)
> > +	{
> > +	  if (create_for_pep)
> > +	    fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG);
> > +	  else
> > +	    fprintf (f, "\t%s\t0\n", ASM_LONG);
> > +	}
> >        fprintf (f, "__IAT_%s:\n", imp_name_lab);
> >      }
> >
> >    if (!no_idata4)
> >      {
> >        fprintf (f, "\t.section\t.didat$4\n");
> > -      fprintf (f, "\t%s\t0\n", ASM_LONG);
> > -      if (create_for_pep)
> > -	fprintf (f, "\t%s\t0\n", ASM_LONG);
> > -      fprintf (f, "\t.section\t.didat$4\n");
> > +      if (use_nul_prefixed_import_tables)
> > +	{
> > +	  fprintf (f, "\t%s\t0\n", ASM_LONG);
> > +	  if (create_for_pep)
> > +	    fprintf (f, "\t%s\t0\n", ASM_LONG);
> > +	}
> >        fprintf (f, "__INT_%s:\n", imp_name_lab);
> >      }
>
> .... these changes. They aren't related to the subject of the patch, are they?
> Instead they mirror into this function what make_head() had gained by commit
> e77b97d43359. I can only guess that the introduction of delay-import support
> (later the same year) was in flight for too long, not noticing the
> intermediate change to the handling of ordinary imports.
>
> IOW unless you can clarify things otherwise, I think this part needs breaking
> out, to then come with its own explanation / justification.

OK.  I was carefully going through the linker output to make sure that
there was no .didat section if there were no delay imports, and that
everything went into the sections I expected, and I noticed these extra
zeros that shouldn't have been there.  I will split that change into a
separate patch for a v2 series.


More information about the Binutils mailing list