--- /dev/null
+# This shell script emits a C file. -*- C -*-
+# It does some substitutions.
+cat >e${EMULATION_NAME}.c <<EOF
+/* For WINDOWS_NT */
+/* This file is a copy of ei385coff which was originally generated on a Linux
+ system. It has been modified to provide a decent default script file
+ for the NT PE format. */
+
+/* The original file generated returned different default scripts depending
+ on whether certain switches were set, but these switches pertain to the
+ Linux system and that particular version of coff. In the NT case, we
+ only determine if the subsystem is console or windows in order to select
+ the correct entry point by default. */
+
+
+/* emulate the original gld for the given i386pe
+ Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+ Written by Steve Chamberlain steve@cygnus.com
+
+This file is part of GLD, the Gnu Linker.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define TARGET_IS_i386pe
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+
+#include "ld.h"
+#include "config.h"
+#include "ldmain.h"
+#include "ldemul.h"
+#include "ldfile.h"
+#include "ldmisc.h"
+
+static void gldi386pe_before_parse PARAMS ((void));
+static char *gldi386pe_get_script PARAMS ((int *isfile));
+
+static void
+gldi386pe_before_parse()
+{
+#ifndef TARGET_ /* I.e., if not generic. */
+ ldfile_output_architecture = bfd_arch_i386;
+#endif /* not TARGET_ */
+}
+
+static char *
+gldi386pe_get_script(isfile)
+ int *isfile;
+{
+ *isfile = 0;
+
+ if (link_info.subsystem == windows)
+ return
+"OUTPUT_FORMAT(\"coff-i386\")\n\
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/i386-coff/lib);\n\
+ENTRY(_WinMainCRTStartup)\n\
+SECTIONS\n\
+{\n\
+ .text 0x401000 : {\n\
+ *(.text)\n\
+ ;\n\
+ }\n\
+ .bss BLOCK(0x1000) :\n\
+ { \n\
+ *(.bss)\n\
+ *(COMMON)\n\
+ ;\n\
+ }\n\
+ .rdata BLOCK(0x1000) :\n\
+ { \n\
+ *(.rdata)\n\
+ ;\n\
+ }\n\
+ .data BLOCK(0x1000) : {\n\
+ *(.data)\n\
+ *(.data2)\n\
+ ;\n\
+ }\n\
+ .idata BLOCK(0x1000) :\n\
+ { \n\
+ *(.idata$2)\n\
+ *(.idata$3)\n\
+ *(.idata$4)\n\
+ *(.idata$5)\n\
+ *(.idata$6)\n\
+ *(.idata$7)\n\
+ ;\n\
+ }\n\
+ .CRT BLOCK(0x1000) :\n\
+ { \n\
+ *(.CRT$XCA)\n\
+ *(.CRT$XCC)\n\
+ *(.CRT$XCZ)\n\
+ *(.CRT$XIA)\n\
+ *(.CRT$XIC)\n\
+ *(.CRT$XIZ)\n\
+ *(.CRT$XLA)\n\
+ *(.CRT$XLZ)\n\
+ *(.CRT$XPA)\n\
+ *(.CRT$XPX)\n\
+ *(.CRT$XPZ)\n\
+ *(.CRT$XTA)\n\
+ *(.CRT$XTZ)\n\
+ ;\n\
+ }\n\
+ .rsrc BLOCK(0x1000) :\n\
+ { \n\
+ *(.rsrc$01)\n\
+ *(.rsrc$02)\n\
+ ;\n\
+ }\n\
+ .reloc BLOCK(0x1000) :\n\
+ { \n\
+ *(.reloc)\n\
+ ;\n\
+ }\n\
+ .junk BLOCK(0x1000) :\n\
+ { \n\
+ *(.debug$S)\n\
+ *(.debug$T)\n\
+ *(.debug$F)\n\
+ *(.drectve)\n\
+ ;\n\
+ }\n\
+}\n\n"
+ ; else return
+"OUTPUT_FORMAT(\"coff-i386\")\n\
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/i386-coff/lib);\n\
+ENTRY(_mainCRTStartup)\n\
+SECTIONS\n\
+{\n\
+ .text 0x401000 : {\n\
+ *(.text)\n\
+ ;\n\
+ }\n\
+ .bss BLOCK(0x1000) :\n\
+ { \n\
+ *(.bss)\n\
+ *(COMMON)\n\
+ ;\n\
+ }\n\
+ .rdata BLOCK(0x1000) :\n\
+ { \n\
+ *(.rdata)\n\
+ ;\n\
+ }\n\
+ .data BLOCK(0x1000) : {\n\
+ *(.data)\n\
+ *(.data2)\n\
+ ;\n\
+ }\n\
+ .idata BLOCK(0x1000) :\n\
+ { \n\
+ *(.idata$2)\n\
+ *(.idata$3)\n\
+ *(.idata$4)\n\
+ *(.idata$5)\n\
+ *(.idata$6)\n\
+ *(.idata$7)\n\
+ ;\n\
+ }\n\
+ .CRT BLOCK(0x1000) :\n\
+ { \n\
+ *(.CRT$XCA)\n\
+ *(.CRT$XCC)\n\
+ *(.CRT$XCZ)\n\
+ *(.CRT$XIA)\n\
+ *(.CRT$XIC)\n\
+ *(.CRT$XIZ)\n\
+ *(.CRT$XLA)\n\
+ *(.CRT$XLZ)\n\
+ *(.CRT$XPA)\n\
+ *(.CRT$XPX)\n\
+ *(.CRT$XPZ)\n\
+ *(.CRT$XTA)\n\
+ *(.CRT$XTZ)\n\
+ ;\n\
+ }\n\
+ .rsrc BLOCK(0x1000) :\n\
+ { \n\
+ *(.rsrc$01)\n\
+ *(.rsrc$02)\n\
+ ;\n\
+ }\n\
+ .reloc BLOCK(0x1000) :\n\
+ { \n\
+ *(.reloc)\n\
+ ;\n\
+ }\n\
+ .junk BLOCK(0x1000) :\n\
+ { \n\
+ *(.debug$S)\n\
+ *(.debug$T)\n\
+ *(.debug$F)\n\
+ *(.drectve)\n\
+ ;\n\
+ }\n\
+}\n\n"
+ ;
+}
+
+struct ld_emulation_xfer_struct ld_i386pe_emulation =
+{
+ gldi386pe_before_parse,
+ syslib_default,
+ hll_default,
+ after_parse_default,
+ after_allocation_default,
+ set_output_arch_default,
+ ldemul_default_target,
+ before_allocation_default,
+ gldi386pe_get_script,
+ "i386pe",
+ "pe-i386"
+};
+EOF
\ No newline at end of file
called by ENTRY in a linker script. Command line arguments take
precedence. */
+/* WINDOWS_NT. When an entry point has been specified, we will also force
+ this symbol to be defined by calling ldlang_add_undef (equivalent to
+ having switch -u entry_name on the command line). The reason we do
+ this is so that the user doesn't have to because they would have to use
+ the -u switch if they were specifying an entry point other than
+ _mainCRTStartup. Specifically, if creating a windows application, entry
+ point _WinMainCRTStartup must be specified.
+ What I have found for non console applications (entry not _mainCRTStartup)
+ is that the .obj that contains mainCRTStartup is brought in since it is
+ the first encountered in libc.lib and it has other symbols in it which will
+ be pulled in by the link process. To avoid this, adding -u with the entry
+ point name specified forces the correct .obj to be used. We can avoid
+ making the user do this by always adding the entry point name as an
+ undefined symbol. */
+
void
lang_add_entry (name, cmdline)
CONST char *name;
entry_symbol = name;
from_cmdline = cmdline;
}
+#ifdef 0 /* WINDOWS_NT */
+ /* don't do this yet. It seems to work (the executables run), but the
+ image created is very different from what I was getting before indicating
+ that something else is being pulled in. When everything else is working,
+ then try to put this back in to see if it will do the right thing for
+ other more complicated applications */
+ ldlang_add_undef (name);
+#endif
}
void