From 9086a9bc1ced017c2c70d5a44a4bc9d4bd36d274 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Fri, 30 Sep 1994 17:33:35 -0400 Subject: [PATCH] Initial revision From-SVN: r8187 --- gcc/config/i386/config-nt.sed | 66 +++++++++ gcc/config/i386/win-nt.h | 79 +++++++++++ gcc/config/winnt/ld.c | 259 ++++++++++++++++++++++++++++++++++ gcc/config/winnt/win-nt.h | 66 +++++++++ gcc/config/winnt/xm-winnt.h | 59 ++++++++ 5 files changed, 529 insertions(+) create mode 100644 gcc/config/i386/config-nt.sed create mode 100644 gcc/config/i386/win-nt.h create mode 100644 gcc/config/winnt/ld.c create mode 100644 gcc/config/winnt/win-nt.h create mode 100644 gcc/config/winnt/xm-winnt.h diff --git a/gcc/config/i386/config-nt.sed b/gcc/config/i386/config-nt.sed new file mode 100644 index 00000000000..d9a6c23454f --- /dev/null +++ b/gcc/config/i386/config-nt.sed @@ -0,0 +1,66 @@ +#/\.o[ ]*:/ s/config.status// +/^multilib.h/ s/multilib/not-multilib/ +/^target=/ c\ +target=winnt3.1 +/^xmake_file=/ d +/^tmake_file=/ d +/^version=/ c\ +version=2.6.0 +s/CC = cc/CC = gcc/ +s/:\$/: \$/g +s/<\ *\$(srcdir)\//< $(srcdir)\\/g +s/^ \$(srcdir)\/move-if-change/ copy/ +s/^USE_/# USE_/ +s/`echo \$(srcdir)\///g +s/ | sed 's,\^\\\.\/,,'`//g +s/^ cd \$(srcdir)[ ]*;/ / +/^# USE_HOST_OBSTACK/ i\ +USE_HOST_OBSTACK=obstack.o +/^stamp-attrtab/,/copy/ { + /\\/d + /fi/d + /copy/ i\ + genattrtab md > tmp-attrtab.c +} +/^enquire[ ]*:/ s/\$(GCC_PARTS)//g +/^enquire.o[ ]*:/ s/\$(GCC_PASSES)//g +/^GCC_FOR_TARGET =/ c\ +GCC_FOR_TARGET = gcc +s/; *@true// +/^OBJS.*stamp-objlist/ s?`cat ../stamp-objlist`?@../stamp-objlist? +s/^\(SUBDIR_OBSTACK *=\).*$/\1 ..\/obstack.o/ +s/^\(SUBDIR_USE_ALLOCA *=\).*$/\1/ +s/^\(SUBDIR_MALLOC *=\).*$/\1/ +/####target/ r config/winnt/t-winnt +/####host/ r config/winnt/x-winnt +s/^C c:/# C c:/ +s/\${OBJS}/\$(OBJS)/g +s/\${SYSTEM_HEADER_DIR}/\$(SYSTEM_HEADER_DIR)/g +s/\${HOST_CC}/\$(HOST_CC)/g +s/ \${srcdir}\// /g +s/\${mainversion}/\$(mainversion)/g +s/\ $(srcdir)\/move-if-change$// +s/\$(srcdir)\/move-if-change/mv/g +/^# USE_HOST_OBSTACK/ i\ +USE_HOST_OBSTACK=obstack.o +s/ \.\// / +s/^bi-\([a-z]*\) *:/bi-\1.exe :/ +s/ bi-\([a-z]*\)$/ bi-\1.exe/ +s/ bi-\([a-z]*\) / bi-\1.exe /g +s/^gen\([a-z]*\) *:/gen\1.exe :/ +s/ gen\([a-z]*\)$/ gen\1.exe/ +s/ gen\([a-z]*\) / gen\1.exe /g +s/genmultilib.exe/genmultilib/g +s/^cccp *:/cccp.exe :/ +s/cccp$/cccp.exe/ +s/cccp /cccp.exe / +s/^cc1 *:/cc1.exe :/ +s/cc1$/cc1.exe/ +s/cc1 /cc1.exe / +s/^xgcc *:/xgcc.exe :/ +s/xgcc$/xgcc.exe/ +s/xgcc /xgcc.exe / +s/^ld *:/ld.exe :/ +s/ld$/ld.exe/ +s/ld /ld.exe / +s/^\ // diff --git a/gcc/config/i386/win-nt.h b/gcc/config/i386/win-nt.h new file mode 100644 index 00000000000..09cba358e4b --- /dev/null +++ b/gcc/config/i386/win-nt.h @@ -0,0 +1,79 @@ +/* Definitions of target machine for GNU compiler + for an Intel i386 or later processor running Windows NT 3.x. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define YES_UNDERSCORES + +#include "i386/gas.h" +#include "winnt/winnt.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DWINNT -D_M_IX86 -D_X86_ -D__STDC__=0 \ + -DALMOST_STDC -Asystem(unix) -Asystem(winnt) -Acpu(i386) -Amachine(i386)" + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_ctor, in_dtor + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CTOR_SECTION_FUNCTION \ + DTOR_SECTION_FUNCTION + +#undef CTOR_SECTION_FUNCTION +#define CTOR_SECTION_FUNCTION \ +void \ +ctor_section () \ +{ \ + if (in_section != in_ctor) \ + { \ + fprintf (asm_out_file, "\t.section .ctor\n"); \ + in_section = in_ctor; \ + } \ +} + +#undef DTOR_SECTION_FUNCTION +#define DTOR_SECTION_FUNCTION \ +void \ +dtor_section () \ +{ \ + if (in_section != in_dtor) \ + { \ + fprintf (asm_out_file, "\t.section .dtor\n"); \ + in_section = in_dtor; \ + } \ +} + +#undef ASM_OUTPUT_CONSTRUCTOR +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + ctor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +#undef ASM_OUTPUT_DESTRUCTOR +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + dtor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) diff --git a/gcc/config/winnt/ld.c b/gcc/config/winnt/ld.c new file mode 100644 index 00000000000..91dabce7424 --- /dev/null +++ b/gcc/config/winnt/ld.c @@ -0,0 +1,259 @@ +/* Call Windows NT 3.x linker. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "config.h" +#include +#include +#include +#include +#include +#include + +/* These can be set by command line arguments */ +char *linker_path = 0; +int verbose = 0; + +int link_arg_max = -1; +char **link_args = (char **) 0; +int link_arg_index = -1; + +char *search_dirs = "."; + +static int is_regular_file (char *name); + +static void +addarg (str) + char *str; +{ + int i; + + if (++link_arg_index >= link_arg_max) + { + char **new_link_args + = (char **) calloc (link_arg_max + 1000, sizeof (char *)); + + for (i = 0; i <= link_arg_max; i++) + new_link_args [i] = link_args [i]; + + if (link_args) + free (link_args); + + link_arg_max += 1000; + link_args = new_link_args; + } + + link_args [link_arg_index] = str; +} + +static char * +locate_file (file_name, path_val) + char *file_name; + char *path_val; +{ + char buf [1000]; + int file_len = strlen (file_name); + char *end_path = path_val + strlen (path_val); + char *ptr; + + /* Handle absolute pathnames */ + if (file_name [0] == '/' || file_name [0] == DIR_SEPARATOR + || isalpha (file_name [0]) && file_name [1] == ':') + { + strncpy (buf, file_name, sizeof buf); + buf[sizeof buf - 1] = '\0'; + if (is_regular_file (buf)) + return strdup (buf); + else + return 0; + } + + if (! path_val) + return 0; + + for (;;) + { + for (; *path_val == PATH_SEPARATOR ; path_val++) + ; + if (! *path_val) + return 0; + + for (ptr = buf; *path_val && *path_val != PATH_SEPARATOR; ) + *ptr++ = *path_val++; + + ptr--; + if (*ptr != '/' && *ptr != DIR_SEPARATOR) + *++ptr = DIR_SEPARATOR; + + strcpy (++ptr, file_name); + + if (is_regular_file (buf)) + return strdup (buf); + } + + return 0; +} + +static char * +expand_lib (name) + char *name; +{ + char *lib, *lib_path; + + lib = malloc (strlen (name) + 5); + strcpy (lib, "lib"); + strcat (lib, name); + strcat (lib, ".a"); + lib_path = locate_file (lib, search_dirs); + if (!lib_path) + { + fprintf (stderr, "Couldn't locate library: %s\n", lib); + exit (1); + } + + return lib_path; +} + +static int +is_regular_file (name) + char *name; +{ + int ret; + struct stat statbuf; + + ret = stat(name, &statbuf); + return !ret && S_ISREG (statbuf.st_mode); +} + +static void +process_args (p_argc, argv) + int *p_argc; + char *argv[]; +{ + int i, j; + + for (i = 1; i < *p_argc; i++) + { + /* -v turns on verbose option here and is passed on to gcc */ + if (! strcmp (argv [i], "-v")) + verbose = 1; + } +} + +main (argc, argv) + int argc; + char *argv[]; +{ + int i; + int done_an_ali = 0; + int file_name_index; + char *pathval = getenv ("PATH"); + char *spawn_args [5]; + char *tmppathval = malloc (strlen (pathval) + 3); + + strcpy (tmppathval, ".;"); + pathval = strcat (tmppathval, pathval); + + process_args (&argc , argv); + + linker_path = locate_file ("link32.exe", pathval); + if (!linker_path) + { + linker_path = locate_file ("link.exe", pathval); + if (!linker_path) + { + fprintf (stderr, "Couldn't locate link32 or link\n"); + exit (1); + } + } + + addarg (linker_path); + + for (i = 1; i < argc; i++) + { + int arg_len = strlen (argv [i]); + + if (!strcmp (argv [i], "-o")) + { + char *buff, *ptr; + int out_len; + + i++; + out_len = strlen (argv[i]) + 9; + buff = malloc (out_len); + strcpy (buff, "-out:"); + strcat (buff, argv[i]); + ptr = strstr (buff, ".exe"); + if (ptr == NULL || strlen (ptr) != 4) + strcat (buff, ".exe"); + addarg (buff); + } + else if (arg_len > 2 && !strncmp (argv [i], "-L", 2)) + { + char *nbuff, *sdbuff; + int j, new_len, search_dirs_len; + + new_len = strlen (&argv[i][2]); + search_dirs_len = strlen (search_dirs); + + nbuff = malloc (new_len); + strcpy (nbuff, &argv[i][2]); + + for (j = 0; j < new_len; j++) + if (nbuff[j] == '/') nbuff[j] = DIR_SEPARATOR; + + sdbuff = malloc (search_dirs_len + new_len + 1); + strcpy (sdbuff, search_dirs); + sdbuff[search_dirs_len] = PATH_SEPARATOR; + sdbuff[search_dirs_len+1] = 0; + strcat (sdbuff, nbuff); + + if (search_dirs) + free (search_dirs); + + search_dirs = sdbuff; + } + + else if (arg_len > 2 && !strncmp (argv [i], "-l", 2)) + addarg (expand_lib (&argv[i][2])); + else if (!strcmp (argv [i], "-v")) + ; + else + addarg (argv [i]); + } + + addarg (NULL); + + if (verbose) + { + int i; + + for (i = 0; i < link_arg_index; i++) + printf ("%s ", link_args [i]); + putchar ('\n'); + } + + if (spawnvp (P_WAIT, linker_path, (const char * const *)link_args) != 0) + { + fprintf (stderr, "Error executing %s\n", link_args[0]); + exit (1); + } + + exit (0); +} diff --git a/gcc/config/winnt/win-nt.h b/gcc/config/winnt/win-nt.h new file mode 100644 index 00000000000..3d4c1ee5284 --- /dev/null +++ b/gcc/config/winnt/win-nt.h @@ -0,0 +1,66 @@ +/* winnt.h -- operating system specific defines to be used when + targeting GCC for Windows NT 3.x. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + + To use this file, put in your tm.h file something like: + + #include "?????.h" + #include "svr4.h" + + followed by any really system-specific defines (or overrides of + defines) which you find that you need. For example, CPP_PREDEFINES + is defined here with only the defined -Dunix and -DSVR4. You should + probably override that in your target-specific ?????svr4.h file + with a set of defines that includes these, but also contains an + appropriate define for the type of hardware that you are targeting. */ + +#undef LIB_SPEC +#define LIB_SPEC "libc.lib kernel32.lib" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "" + +#undef LINK_SPEC +#define LINK_SPEC "-align:0x1000 -subsystem:console -entry:mainCRTStartup \ + -stack:1000000,1000000" + +#undef STANDARD_EXEC_PREFIX +#define STANDARD_EXEC_PREFIX "" + +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "" + +#undef TOOLDIR_BASE_PREFIX +#define TOOLDIR_BASE_PREFIX "" + +#ifdef STANDARD_INCLUDE_DIR +#undef STANDARD_INCLUDE_DIR +#endif +#define STANDARD_INCLUDE_DIR "" + +#undef LOCAL_INCLUDE_DIR +#define LOCAL_INCLUDE_DIR "" + +#undef INCLUDE_DEFAULTS +#define INCLUDE_DEFAULTS \ + { \ + { 0, 0, 0 } \ + } + diff --git a/gcc/config/winnt/xm-winnt.h b/gcc/config/winnt/xm-winnt.h new file mode 100644 index 00000000000..3a303990d71 --- /dev/null +++ b/gcc/config/winnt/xm-winnt.h @@ -0,0 +1,59 @@ +/* Configuration for GNU compiler + for processor running Windows NT 3.x. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#define USG +#define ONLY_INT_FIELDS +#define USE_PROTOTYPES 1 +#define bcmp(a,b,c) memcmp (a,b,c) +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define index strchr +#define rindex strrchr +#define kill(a,b) raise(b) + +#define EXECUTABLE_SUFFIX ".exe" +#define PATH_SEPARATOR ';' +#define DIR_SEPARATOR '\\' +#define HAVE_PUTENV 1 + +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 +#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) + +#define access _access +#define close _close +#define dup _dup +#define mktemp _mktemp +#define open _open +#define read _read +#define write _write +#define chmod _chmod +#define setjmp _setjmp -- 2.30.2