+ abfd = bfd_openr (TMP_HEAD_O, HOW_BFD_READ_TARGET);
+ if (abfd == NULL)
+ /* xgettext:c-format */
+ fatal (_("failed to open temporary head file: %s: %s"),
+ TMP_HEAD_O, bfd_get_errmsg ());
+
+ temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O;
+ return abfd;
+}
+
+bfd *
+make_delay_head (void)
+{
+ FILE *f = fopen (TMP_HEAD_S, FOPEN_WT);
+ bfd *abfd;
+
+ if (f == NULL)
+ {
+ fatal (_("failed to open temporary head file: %s"), TMP_HEAD_S);
+ return NULL;
+ }
+
+ temp_file_to_remove[TEMP_HEAD_FILE] = TMP_HEAD_S;
+
+ /* Output the __tailMerge__xxx function */
+ fprintf (f, "%s Import trampoline\n", ASM_C);
+ fprintf (f, "\t.section\t.text\n");
+ fprintf(f,"\t%s\t%s\n", ASM_GLOBAL, head_label);
+ fprintf (f, "%s:\n", head_label);
+ fprintf (f, mtable[machine].trampoline, imp_name_lab);
+
+ /* Output the delay import descriptor */
+ fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C);
+ fprintf (f, ".section\t.text$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);
+ fprintf (f, "\t%s__%s_iname%s\t%s rvaDLLName\n",
+ ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C);
+ fprintf (f, "\t%s__DLL_HANDLE_%s%s\t%s rvaHmod\n",
+ ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C);
+ fprintf (f, "\t%s__IAT_%s%s\t%s rvaIAT\n",
+ ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C);
+ fprintf (f, "\t%s__INT_%s%s\t%s rvaINT\n",
+ ASM_RVA_BEFORE, imp_name_lab, ASM_RVA_AFTER, ASM_C);
+ fprintf (f, "\t%s\t0\t%s rvaBoundIAT\n", ASM_LONG, ASM_C);
+ fprintf (f, "\t%s\t0\t%s rvaUnloadIAT\n", ASM_LONG, ASM_C);
+ fprintf (f, "\t%s\t0\t%s dwTimeStamp\n", ASM_LONG, ASM_C);
+
+ /* Output the dll_handle */
+ fprintf (f, "\n.section .data\n");
+ fprintf (f, "__DLL_HANDLE_%s:\n", imp_name_lab);
+ fprintf (f, "\t%s\t0\t%s Handle\n", ASM_LONG, ASM_C);
+ if (create_for_pep)
+ fprintf (f, "\t%s\t0\n", ASM_LONG);
+ fprintf (f, "\n");
+
+ fprintf (f, "%sStuff for compatibility\n", ASM_C);
+
+ if (!no_idata5)
+ {
+ fprintf (f, "\t.section\t.idata$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);
+ fprintf (f, "__IAT_%s:\n", imp_name_lab);
+ }
+
+ if (!no_idata4)
+ {
+ fprintf (f, "\t.section\t.idata$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.idata$4\n");
+ fprintf (f, "__INT_%s:\n", imp_name_lab);
+ }
+
+ fprintf (f, "\t.section\t.idata$2\n");
+
+ fclose (f);
+
+ assemble_file (TMP_HEAD_S, TMP_HEAD_O);
+
+ abfd = bfd_openr (TMP_HEAD_O, HOW_BFD_READ_TARGET);
+ if (abfd == NULL)
+ /* xgettext:c-format */
+ fatal (_("failed to open temporary head file: %s: %s"),
+ TMP_HEAD_O, bfd_get_errmsg ());
+
+ temp_file_to_remove[TEMP_HEAD_O_FILE] = TMP_HEAD_O;
+ return abfd;