]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld,dlltool: move read-only delayimp data into .rdata
authorJeremy Drake <sourceware-bugzilla@jdrake.com>
Fri, 13 Jun 2025 05:52:47 +0000 (07:52 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 13 Jun 2025 05:52:47 +0000 (07:52 +0200)
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
ld/scripttempl/pe.sc
ld/scripttempl/pep.sc

index 0e0138305f4385c3492a35852dd533712db81fd3..4b08638f792dd1aec26fdeecadaba5565e7b0644 100644 (file)
@@ -2798,7 +2798,7 @@ make_delay_head (void)
 
   /* Output the delay import descriptor */
   fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C);
-  fprintf (f, ".section\t.text$2\n");
+  fprintf (f, ".section\t.didat$2\n");
   fprintf (f, "%s __DELAY_IMPORT_DESCRIPTOR_%s\n", ASM_GLOBAL,imp_name_lab);
   fprintf (f, "__DELAY_IMPORT_DESCRIPTOR_%s:\n", imp_name_lab);
   fprintf (f, "\t%s 1\t%s grAttrs\n", ASM_LONG, ASM_C);
@@ -2841,12 +2841,9 @@ make_delay_head (void)
       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");
       fprintf (f, "__INT_%s:\n", imp_name_lab);
     }
 
-  fprintf (f, "\t.section\t.didat$2\n");
-
   fclose (f);
 
   assemble_file (TMP_HEAD_S, TMP_HEAD_O);
index 108c6fb2cdff305826b0e1ff73abbd5312c585a5..8fb98b2c06e479bf4d1b53e5ab39dd14ae4a22fe 100644 (file)
@@ -146,6 +146,11 @@ SECTIONS
     ${RELOCATING+__rt_psrelocs_start = .;}
     ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))}
     ${RELOCATING+__rt_psrelocs_end = .;}
+    /* read-only parts of .didat */
+    /* This cannot currently be handled with grouped sections.
+       See pe.em:sort_sections.  */
+    ${R_DIDAT234}
+    ${R_DIDAT67}
 
     /* .ctors & .dtors */
     ${CONSTRUCTING+
@@ -263,9 +268,7 @@ SECTIONS
   {
     /* This cannot currently be handled with grouped sections.
        See pe.em:sort_sections.  */
-    ${R_DIDAT234}
     ${R_DIDAT5}
-    ${R_DIDAT67}
   }
 
   /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
index f508ebe558531e0fbceea18431846a2392ba6d15..841ee352f7334dffd848576fdbfa3c0d7a325201 100644 (file)
@@ -148,6 +148,12 @@ SECTIONS
     ${RELOCATING+__rt_psrelocs_start = .;}
     ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))}
     ${RELOCATING+__rt_psrelocs_end = .;}
+    /* read-only parts of .didat */
+    /* This cannot currently be handled with grouped sections.
+       See pe.em:sort_sections.  */
+    ${RELOCATING+. = ALIGN(8);}
+    ${R_DIDAT234}
+    ${R_DIDAT67}
 
     /* .ctors & .dtors */
     ${CONSTRUCTING+. = ALIGN(8);}
@@ -271,9 +277,7 @@ SECTIONS
   {
     /* This cannot currently be handled with grouped sections.
        See pep.em:sort_sections.  */
-    ${R_DIDAT234}
     ${R_DIDAT5}
-    ${R_DIDAT67}
   }
 
   /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be