diff options
author | Ben Cheng <bccheng@google.com> | 2012-10-01 10:30:31 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2012-10-01 10:30:31 -0700 |
commit | 82bcbebce43f0227f506d75a5b764b6847041bae (patch) | |
tree | fe9f8597b48a430c4daeb5123e3e8eb28e6f9da9 /gcc-4.7/gcc/config/vms | |
parent | 3c052de3bb16ac53b6b6ed659ec7557eb84c7590 (diff) | |
download | toolchain_gcc-82bcbebce43f0227f506d75a5b764b6847041bae.tar.gz toolchain_gcc-82bcbebce43f0227f506d75a5b764b6847041bae.tar.bz2 toolchain_gcc-82bcbebce43f0227f506d75a5b764b6847041bae.zip |
Initial check-in of gcc 4.7.2.
Change-Id: I4a2f5a921c21741a0e18bda986d77e5f1bef0365
Diffstat (limited to 'gcc-4.7/gcc/config/vms')
-rw-r--r-- | gcc-4.7/gcc/config/vms/make-crtlmap.awk | 55 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/t-vms | 41 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/t-vmsnative | 30 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms-ar.c | 348 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms-c.c | 332 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms-crtlmap.map | 201 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms-ld.c | 968 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms-protos.h | 31 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms.c | 194 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms.h | 67 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms.opt | 31 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/vms64.h | 29 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/x-vms | 27 | ||||
-rw-r--r-- | gcc-4.7/gcc/config/vms/xm-vms.h | 64 |
14 files changed, 2418 insertions, 0 deletions
diff --git a/gcc-4.7/gcc/config/vms/make-crtlmap.awk b/gcc-4.7/gcc/config/vms/make-crtlmap.awk new file mode 100644 index 000000000..6f82dee7a --- /dev/null +++ b/gcc-4.7/gcc/config/vms/make-crtlmap.awk @@ -0,0 +1,55 @@ +# Generate the VMS crtl map +# Copyright (C) 2011 Free Software Foundation, Inc. + +BEGIN { + is_first = 1; + maxlen=1; + maxlen_name="??" + prev="" + ORS="" +} + +# Remove comment and blank lines. +/^ *#/ || /^ *$/ { + next; +} + +{ + # Handle comma + if (!is_first) + print ",\n" + else + is_first = 0; + + # Check the map is sorted + if ($0 <= prev) + { + print "Map not sorted!! (with name " $0 ")\n" + exit 1 + } + prev = $0 + + # Compute the max of the identifier len. + l=length($1) + if (l > maxlen) + { + maxlen = l + maxlen_name = $1 + } + + print "{ \"" $1 "\", " + if (NF == 1) + print "0 }" + else if (NF == 2) + printf "VMS_CRTL_" $2 " }" + else if (NF == 3) + printf "VMS_CRTL_" $2 " | VMS_CRTL_" $3 " }" + else + # To be fixed. + exit 1 +} + +END { + print "\n\n" + print "#define VMS_CRTL_MAXLEN " maxlen " /*" maxlen_name " */\n" +} diff --git a/gcc-4.7/gcc/config/vms/t-vms b/gcc-4.7/gcc/config/vms/t-vms new file mode 100644 index 000000000..6af3df806 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/t-vms @@ -0,0 +1,41 @@ +# Copyright (C) 2009, 2010, 2011 +# Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC 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 3, or (at your option) +# any later version. +# +# GCC 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 GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +STMP_FIXPROTO = +STMP_FIXINC = +LIMITS_H_TEST = false + +# Under VMS, directory names cannot contain dots. +version:=$(shell echo $(BASEVER_c) | sed -e 's/\./_/g') + +vms-crtlmap.h: $(srcdir)/config/vms/vms-crtlmap.map \ + $(srcdir)/config/vms/make-crtlmap.awk + $(AWK) -f $(srcdir)/config/vms/make-crtlmap.awk \ + $(srcdir)/config/vms/vms-crtlmap.map > $@ + +vms.o: $(srcdir)/config/vms/vms.c $(TREE_H) $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(TM_P_H) vms-crtlmap.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $< -o $@ + +vms-c.o: $(srcdir)/config/vms/vms-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) $(CPPLIB_H) $(TREE_H) c-family/c-pragma.h toplev.h $(GGC_H) \ + $(TM_P_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(PREPROCESSOR_DEFINES) $< -o $@ diff --git a/gcc-4.7/gcc/config/vms/t-vmsnative b/gcc-4.7/gcc/config/vms/t-vmsnative new file mode 100644 index 000000000..a7fc031d4 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/t-vmsnative @@ -0,0 +1,30 @@ +# Copyright (C) 2010 +# Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC 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 3, or (at your option) +# any later version. +# +# GCC 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 GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +vms-ld.o: $(srcdir)/config/vms/vms-ld.c + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + +ld$(exeext): vms-ld.o $(LIBIBERTY) + $(CC) -o $@ vms-ld.o $(LIBIBERTY) + +vms-ar.o: $(srcdir)/config/vms/vms-ar.c + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + +ar$(exeext): vms-ar.o $(LIBIBERTY) + $(CC) -o $@ vms-ar.o $(LIBIBERTY) diff --git a/gcc-4.7/gcc/config/vms/vms-ar.c b/gcc-4.7/gcc/config/vms/vms-ar.c new file mode 100644 index 000000000..9f674f07e --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms-ar.c @@ -0,0 +1,348 @@ +/* VMS archive wrapper. + Copyright (C) 2011 Free Software Foundation, Inc. + Contributed by AdaCore. + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "libiberty.h" + +#define FATAL_EXIT_CODE (44 | 0x10000000) + +/* Librarian arguments. */ +static int lib_arg_max = 0; +static const char **lib_args; +static int lib_arg_index = -1; + +/* Set for r/c/x/v command. */ +static int replace_mode = 0; +static int create_mode = 0; +static int extract_mode = 0; +static int verbose_mode = 0; + +static char modecmd[32]; +static char libname[256]; + +#define TEMP_FILE "arXXXXXX" +#define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1) +#define SUFFIX ".com" +#define SUFFIX_LEN (sizeof(SUFFIX) - 1) + +static char *to_host_file_spec (char *filespec); +static int is_regular_file (char *name); + +#ifdef VMS +static char new_host_filespec [255]; +static char filename_buff [256]; + +static int +translate_unix (char *name, int type) +{ + strcpy (filename_buff, name); + return 0; +} +#endif + +static char * +to_host_file_spec (char *filespec) +{ +#ifdef VMS + if (strchr (filespec, ']') || strchr (filespec, ':')) + return filespec; + else + { + strcpy (filename_buff, filespec); + decc$to_vms (filespec, translate_unix, 1, 1); + strcpy (new_host_filespec, filename_buff); + return new_host_filespec; + } +#else + return filespec; +#endif +} + +/* Check to see if the file named in NAME is a regular file, i.e. not a + directory. */ + +static int +is_regular_file (char *name) +{ + int ret; + struct stat statbuf; + + ret = stat (name, &statbuf); + return !ret && S_ISREG (statbuf.st_mode); +} + +/* Add the argument contained in STR to the list of arguments to pass to the + archiver. */ + +static void +addarg (const char *str) +{ + if (++lib_arg_index >= lib_arg_max) + { + lib_arg_max += 1000; + lib_args = XRESIZEVEC (const char *, lib_args, lib_arg_max); + } + + lib_args[lib_arg_index] = str; +} + +static void +usage (void) +{ + printf ("usage: ar -r [-cv] archive file...\n"); + printf (" ar -c [-rv] archive file...\n"); + printf (" ar -x [-v] archive [module...]\n"); +} + +int +main (int argc, char *argv[]) +{ + int i, nexti, iarg; + FILE *comfile; + int comfd; + int outlen, maxoutlen = 4000; + char temp_filename[] = TEMP_FILE SUFFIX; + char command[256]; + int status; + + if (argc < 2) + { + fprintf (stderr, "ar: no command or archive\n"); + exit (FATAL_EXIT_CODE); + } + + if (argv[1][0] != '-') + { + int arglen = strlen (argv[1]); + + /* Compatibility mode. */ + for (i = 0; i < arglen; i++) + { + if (argv[1][i] == 'r') + { + replace_mode = 1; + } + else if (argv[1][i] == 'c') + { + create_mode = 1; + } + else if (argv[1][i] == 'x') + { + extract_mode = 1; + } + else if (argv[1][i] == 'v') + { + verbose_mode = 1; + } + else + { + fprintf (stderr, "ar: unknown command '%c'\n", argv[1][i]); + exit (FATAL_EXIT_CODE); + } + } + nexti = 2; + } + else + { + /* Option mode. */ + nexti = 1; + for (i = 1; i < argc; i++) + { + if (argv[i][0] != '-') + { + nexti = i; + break; + } + else if (strcmp (argv[i], "-r") == 0) + { + replace_mode = 1; + } + else if (strcmp (argv[i], "-c") == 0) + { + create_mode = 1; + } + else if (strcmp (argv[i], "-x") == 0) + { + extract_mode = 1; + } + else if (strcmp (argv[i], "-v") == 0) + { + verbose_mode = 1; + } + else if (strcmp (argv[i], "--help") == 0) + { + usage (); + exit (EXIT_SUCCESS); + } + else + { + fprintf (stderr, "ar: unknown option %s\n", argv[i]); + exit (FATAL_EXIT_CODE); + } + } + } + + if (extract_mode) + { + do + { + char *lname = argv[nexti]; + int lnamelen; + + /* Next argument is the archive name. */ + if (is_regular_file (lname)) + { + addarg (xstrdup (to_host_file_spec (lname))); + break; + } + + /* If not found, try with .olb instead of .a. */ + lnamelen = strlen (lname); + + if (lnamelen > 2 + && strcmp (&lname [lnamelen - 2], ".a") == 0) + { + char *nlibname; + + nlibname = (char *)alloca (lnamelen + 3); + strcpy (nlibname, lname); + strcpy (&nlibname [lnamelen - 2], ".olb"); + if (is_regular_file (nlibname)) + { + addarg (xstrdup (to_host_file_spec (nlibname))); + break; + } + } + + fprintf (stderr, "ar: file '%s' doesn't exist\n", lname); + exit (FATAL_EXIT_CODE); + } while (0); + } + else + strcpy (libname, to_host_file_spec (argv[nexti])); + + nexti++; + + /* Build command mode. */ + if (replace_mode) + { + strcat (modecmd, "/replace"); + + if (!is_regular_file (libname) || !replace_mode) + { + /* Really create if the archive doesn't exist. */ + strcat (modecmd, "/create"); + } + } + else if (extract_mode) + { + if (nexti == argc) + { + /* Extract all. */ + strcat (modecmd, "/extract=(*"); + } + else + strcat (modecmd, "/extract=("); + } + + /* Add files. */ + for (i = nexti; i < argc; i++) + { + if (extract_mode) + { + /* Convert to module name (remove extension) and quote it. */ + char *module = argv[i]; + int module_len = strlen (module); + char *newarg = (char *)xmalloc (module_len + 3); + int l; + + newarg[0] = '"'; + memcpy (newarg + 1, module, module_len); + + l = 1 + module_len; + if (module_len > 4 + && strcmp (&module[module_len - 4], ".obj") == 0) + l -= 4; + + newarg[l] = '"'; + newarg[l + 1] = 0; + + addarg (newarg); + } + else + { + /* Add the filename. */ + addarg (xstrdup (to_host_file_spec (argv[i]))); + } + } + + if (extract_mode) + addarg (")"); + + /* Create the command file name. */ + strcpy (temp_filename, TEMP_FILE SUFFIX); + comfd = mkstemps (temp_filename, SUFFIX_LEN); + comfile = fdopen (comfd, "w"); + + /* Write the command file. + We need to split to command into severals ones if it is too long. */ + outlen = 0; + for (iarg = 0; iarg <= lib_arg_index; iarg++) + { + if (outlen == 0) + { + fprintf (comfile, "$ library %s %s -\n", modecmd, libname); + if (create_mode && iarg == 0) + strcpy (modecmd, "/replace"); + } + + fprintf (comfile, "%s", lib_args [iarg]); + outlen += strlen (lib_args [iarg]) + 2; + + if (outlen > maxoutlen || iarg == lib_arg_index) + { + /* Will write a new command. */ + fprintf (comfile, "\n"); + outlen = 0; + } + else + { + /* Continuation line. */ + fprintf (comfile, ",-\n"); + } + } + + fclose (comfile); + + sprintf (command, "@%s", temp_filename); + + status = system (command); + + remove (temp_filename); + + exit (status); +} diff --git a/gcc-4.7/gcc/config/vms/vms-c.c b/gcc-4.7/gcc/config/vms/vms-c.c new file mode 100644 index 000000000..b3e0d955f --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms-c.c @@ -0,0 +1,332 @@ +/* VMS specific, C compiler specific functions. + Copyright (C) 2011 + Free Software Foundation, Inc. + Contributed by Tristan Gingold (gingold@adacore.com). + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "cpplib.h" +#include "tree.h" +#include "c-family/c-pragma.h" +#include "c-family/c-common.h" +#include "toplev.h" +#include "ggc.h" +#include "tm_p.h" +#include "incpath.h" +#include "diagnostic.h" + +/* '#pragma __nostandard' is simply ignored. */ + +static void +vms_pragma_nostandard (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + tree x; + + if (pragma_lex (&x) != CPP_EOF) + warning (OPT_Wpragmas, "junk at end of #pragma __nostandard"); +} + +/* '#pragma __standard' is simply ignored. */ + +static void +vms_pragma_standard (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + tree x; + + if (pragma_lex (&x) != CPP_EOF) + warning (OPT_Wpragmas, "junk at end of #pragma __standard"); +} + +/* Saved member alignment. */ +static int saved_member_alignment; + +/* Handle '#pragma member_alignment'. */ + +static void +vms_pragma_member_alignment (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + tree x; + int tok; + const char *arg; + + tok = pragma_lex (&x); + + if (tok == CPP_EOF) + { + /* Disable packing. */ + maximum_field_alignment = initial_max_fld_align; + return; + } + if (tok != CPP_NAME) + { + warning (OPT_Wpragmas, "malformed '#pragma member_alignment', ignoring"); + return; + } + + arg = IDENTIFIER_POINTER (x); + /* Accept '__' prefix. */ + if (arg[0] == '_' && arg[1] == '_') + arg += 2; + + if (strcmp (arg, "save") == 0) + saved_member_alignment = maximum_field_alignment; + else if (strcmp (arg, "restore") == 0) + maximum_field_alignment = saved_member_alignment; + else + { + error ("unknown '#pragma member_alignment' name %s", arg); + return; + } + if (pragma_lex (&x) != CPP_EOF) + { + error ("malformed '#pragma member_alignment'"); + return; + } +} + +/* Handle '#pragma nomember_alignment'. */ + +static void +vms_pragma_nomember_alignment (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + tree x; + int tok; + + tok = pragma_lex (&x); + if (tok == CPP_NAME) + { + const char *arg = IDENTIFIER_POINTER (x); + + /* Accept '__' prefix. */ + if (arg[0] == '_' && arg[1] == '_') + arg += 2; + + if (strcmp (arg, "word") == 0) + maximum_field_alignment = 2 * BITS_PER_UNIT; + else if (strcmp (arg, "longword") == 0) + maximum_field_alignment = 4 * BITS_PER_UNIT; + else if (strcmp (arg, "quadword") == 0) + maximum_field_alignment = 8 * BITS_PER_UNIT; + else + { + error ("unhandled alignment for '#pragma nomember_alignment'"); + } + + tok = pragma_lex (&x); + } + else + { + /* Enable packing. */ + maximum_field_alignment = BITS_PER_UNIT; + } + + if (tok != CPP_EOF) + { + error ("garbage at end of '#pragma nomember_alignment'"); + return; + } +} + +/* The 'extern model' for public data. */ + +enum extern_model_kind +{ + /* Create one overlaid section per variable. */ + extern_model_common_block, + + /* Like unix: multiple not-initialized declarations are allowed. */ + extern_model_relaxed_refdef, + + /* Like -fno-common. */ + extern_model_strict_refdef, + + /* Declarations creates symbols without storage. */ + extern_model_globalvalue +}; + +/* Current and saved extern model. */ +static enum extern_model_kind current_extern_model; +static enum extern_model_kind saved_extern_model; + +/* Partial handling of '#pragma extern_model'. */ + +static void +vms_pragma_extern_model (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + tree x; + int tok; + const char *arg; + + tok = pragma_lex (&x); + + if (tok != CPP_NAME) + { + warning (OPT_Wpragmas, "malformed '#pragma extern_model', ignoring"); + return; + } + + arg = IDENTIFIER_POINTER (x); + /* Accept "__" prefix. */ + if (arg[0] == '_' && arg[1] == '_') + arg += 2; + + if (strcmp (arg, "save") == 0) + saved_extern_model = current_extern_model; + else if (strcmp (arg, "restore") == 0) + current_extern_model = saved_extern_model; + else if (strcmp (arg, "strict_refdef") == 0) + current_extern_model = extern_model_strict_refdef; + else if (strcmp (arg, "common_block") == 0) + current_extern_model = extern_model_common_block; + else if (strcmp (arg, "globalvalue") == 0) + { + sorry ("extern model globalvalue"); + return; + } + else + { + error ("unknown '#pragma extern_model' model '%s'", arg); + return; + } +#if 0 + if (pragma_lex (&x) != CPP_EOF) + { + permerror (input_location, "junk at end of '#pragma extern_model'"); + return; + } +#endif +} + +/* Ignore '#pragma message'. */ + +static void +vms_pragma_message (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + /* Completly ignored. */ +#if 0 + pedwarn (input_location, OPT_Wpragmas, + "vms '#pragma __message' is ignored"); +#endif +} + +/* Handle '#pragma __extern_prefix' */ + +static GTY(()) tree saved_extern_prefix; + +static void +vms_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy)) +{ + enum cpp_ttype tok; + tree x; + + tok = pragma_lex (&x); + if (tok == CPP_NAME) + { + const char *op = IDENTIFIER_POINTER (x); + + if (!strcmp (op, "__save")) + saved_extern_prefix = pragma_extern_prefix; + else if (!strcmp (op, "__restore")) + pragma_extern_prefix = saved_extern_prefix; + else + warning (OPT_Wpragmas, + "malformed '#pragma __extern_prefix', ignoring"); + return; + } + else if (tok != CPP_STRING) + { + warning (OPT_Wpragmas, + "malformed '#pragma __extern_prefix', ignoring"); + } + else + { + /* Note that the length includes the null terminator. */ + pragma_extern_prefix = (TREE_STRING_LENGTH (x) > 1 ? x : NULL); + } +} + +/* Add vms-specific pragma. */ + +void +vms_c_register_pragma (void) +{ + c_register_pragma (NULL, "__nostandard", vms_pragma_nostandard); + c_register_pragma (NULL, "nostandard", vms_pragma_nostandard); + c_register_pragma (NULL, "__standard", vms_pragma_standard); + c_register_pragma (NULL, "standard", vms_pragma_standard); + c_register_pragma (NULL, "__member_alignment", vms_pragma_member_alignment); + c_register_pragma (NULL, "member_alignment", vms_pragma_member_alignment); + c_register_pragma (NULL, "__nomember_alignment", + vms_pragma_nomember_alignment); + c_register_pragma (NULL, "nomember_alignment", + vms_pragma_nomember_alignment); + c_register_pragma (NULL, "__extern_model", vms_pragma_extern_model); + c_register_pragma (NULL, "extern_model", vms_pragma_extern_model); + c_register_pragma (NULL, "__message", vms_pragma_message); + c_register_pragma (NULL, "__extern_prefix", vms_pragma_extern_prefix); +} + +/* Standard modules list. */ +static const char * const vms_std_modules[] = { "rtldef", "starlet_c", NULL }; + +/* Find include modules in the include path. */ + +void +vms_c_register_includes (const char *sysroot, + const char *iprefix ATTRIBUTE_UNUSED, int stdinc) +{ + static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; + struct cpp_dir *dir; + + /* Add on standard include pathes. */ + if (!stdinc) + return; + + for (dir = get_added_cpp_dirs (SYSTEM); dir != NULL; dir = dir->next) + { + const char * const *lib; + for (lib = vms_std_modules; *lib != NULL; lib++) + { + char *path; + struct stat st; + + if (sysroot != NULL) + path = concat (sysroot, dir->name, dir_separator_str, *lib, NULL); + else + path = concat (dir->name, dir_separator_str, *lib, NULL); + + if (stat (path, &st) == 0 && S_ISDIR (st.st_mode)) + { + cpp_dir *p; + + p = XNEW (cpp_dir); + p->next = NULL; + p->name = path; + p->sysp = 1; + p->construct = 0; + p->user_supplied_p = 0; + add_cpp_dir_path (p, SYSTEM); + } + else + free (path); + } + } +} diff --git a/gcc-4.7/gcc/config/vms/vms-crtlmap.map b/gcc-4.7/gcc/config/vms/vms-crtlmap.map new file mode 100644 index 000000000..8df87678a --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms-crtlmap.map @@ -0,0 +1,201 @@ +# Standard C names to DEC-C names map table. +# All names in the DEC-C shared image (shared library) are prefixed +# with decc$ (this is the standard vms convention for names in public +# shared libraries). This conversion is done by the compiler for all +# languages. +# +# Currently contains only a partial list, e.g. those functions use +# in GNAT and GCC. +# +# File format: +# - Empty lines are ignored. +# - Comment lines start with '#' in the first column. +# - map lines consist in an identifier optionnaly followed by at most 2 +# space-separated flags. +# Flags are: +# FLOAT: will be prefixed by 'x' +# 64: There is a 64-bit variant +# BSD44: name will be prefixed by __bsd44__ +# PRNTF: a 't' prefix will be added. +# MALLOC: malloc related function. +# +# Keep entries alpha-sorted - this is enforced by the awk script. +# +__32_signal +__32_ssignal +__64_signal +__64_ssignal +__utc_localtime +__utc_localtime_t +__utc_stat +__utc_time +__utctz_gmtime +__utctz_localtime +__utctz_localtime_t +abort +abs +accept +access +acos FLOAT +alarm +asin FLOAT +atan FLOAT +atan2 FLOAT +atexit +atoi +atoll +atoq +basename 64 +bcmp +bcopy +bsearch 64 +bzero +calloc 64 MALLOC +ceil FLOAT +chdir +chown +clearerr +clock +close +connect +cos FLOAT +ctermid 64 +ctime +dup +dup2 +environ GLOBAL +exit +exp FLOAT +fabs FLOAT +fclose +fdopen +fflush +ffs +fgetc +fgets 64 +floor FLOAT +fopen +fprintf FLOAT PRNTF +fputc +fputs +fread +free +freopen +fseek +ftell +fwrite +getc +getcwd 64 +getegid +getenv +geteuid +getgid +gethostbyaddr +gethostbyname +getpagesize +getpid +getservbyname +getservbyport +gettimeofday +getuid +gmtime +htons +iconv +index 64 +ioctl +isatty +isdigit +islower +isprint +isspace +isupper +kill +localtime +log FLOAT +log10 FLOAT +lseek +malloc 64 MALLOC +mbstowcs 64 +memchr 64 +memcmp +memcpy 64 +memmove 64 +memset 64 +mkdir +mkstemp +mktemp 64 +mmap 64 +munmap +nl_langinfo +open +pclose +perror +popen +pow FLOAT +printf FLOAT PRNTF +putc +putchar +putenv +puts +qsort 64 +random +read +realloc 64 MALLOC +recv +recvfrom +recvmsg BSD44 64 +rename +rewind +rindex 64 +rmdir +send +sendmsg BSD44 64 +sendto +setenv +setlocale +setvbuf +signal +sigsetmask +sin FLOAT +snprintf FLOAT PRNTF +socket +sprintf FLOAT PRNTF +sqrt FLOAT +stat +strcasecmp +strcat 64 +strchr 64 +strcmp +strcpy 64 +strdup 64 MALLOC +strerror +strlen +strncasecmp +strncmp +strncpy 64 +strrchr 64 +strstr 64 +strtod 64 FLOAT +strtol 64 +strtoul 64 +sysconf +system +tan FLOAT +time +times +tmpfile +tmpnam 64 +tolower +toupper +umask +ungetc +unlink +utime +vfprintf FLOAT PRNTF +vprintf FLOAT PRNTF +vsnprintf FLOAT PRNTF +vsprintf FLOAT PRNTF +wait +waitpid +wcswidth +write diff --git a/gcc-4.7/gcc/config/vms/vms-ld.c b/gcc-4.7/gcc/config/vms/vms-ld.c new file mode 100644 index 000000000..cc57d8a24 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms-ld.c @@ -0,0 +1,968 @@ +/* VMS linker wrapper. + Copyright (C) 2011 Free Software Foundation, Inc. + Contributed by AdaCore + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* This program is a wrapper around the VMS linker. + It translates Unix style command line options into corresponding + VMS style qualifiers and then spawns the VMS linker. + + It is possible to build this program on UNIX but only for the purpose of + checking for errors. */ + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> + +#include "libiberty.h" +#include <safe-ctype.h> +#include <sys/stat.h> + +/* Macro for logicals. */ +#define LNM__STRING 2 +#define LNM_C_NAMLENGTH 255 +#define PSL_C_SUPER 2 +#define PSL_C_USER 3 + +/* Local variable declarations. */ +static int ld_nocall_debug = 0; +static int ld_mkthreads = 0; +static int ld_upcalls = 0; + +/* verbose = 1 if -v passed. */ +static int verbose = 0; + +/* save_temps = 1 if -save-temps passed. */ +static int save_temps = 0; + +/* By default don't generate executable file if there are errors + in the link. Override with --noinhibit-exec. */ +static int inhibit_exec = 1; + +/* debug = 1 if -g passed. */ +static int debug = 0; + +/* By default prefer to link with static libraries. */ +static int staticp = 1; + +/* By default generate an executable, not a shareable image library. + Override with -shared. */ +static int share = 0; + +/* Linker command line. */ +static int link_cmd_maxlen = 0; +static char *link_cmd = 0; +static int link_cmd_len = 0; + +/* Keep track of filenames. */ +static char *sharebasename; +static const char *exefullfilename; +static const char *exefilename; + +/* Search dir list passed on command line (with -L). */ +static const char **search_dirs; +static int search_dirs_len; + +/* Local function declarations. */ +static void addarg (const char *); +static int is_regular_file (char *); +static char *to_host_file_spec (char *); +static char *locate_lib (char *); +static const char *expand_lib (char *); +static void preprocess_args (int, char **); +static void process_args (int, char **); +static void maybe_set_link_compat (void); +static int set_exe (const char *); +#ifdef VMS +static int translate_unix (char *, int); +#endif + + +/* Append STR to the command line to invoke the linker. + Expand the line as necessary to accommodate. */ + +static void +addarg (const char *str) +{ + int l = strlen (str); + + /* Extend the line. */ + if (link_cmd_len + l >= link_cmd_maxlen) + { + link_cmd_maxlen = link_cmd_len + l + 1024; + link_cmd = XRESIZEVEC (char, link_cmd, link_cmd_maxlen); + } + + memcpy (link_cmd + link_cmd_len, str, l); + link_cmd_len += l; +} + +/* Check to see if NAME is a regular file, i.e. not a directory. */ + +static int +is_regular_file (char *name) +{ + int ret; + struct stat statbuf; + + ret = stat (name, &statbuf); + return !ret && S_ISREG (statbuf.st_mode); +} + +#ifdef VMS +static char new_host_filespec [255]; +static char filename_buff [256]; + +/* Action routine called by decc$to_vms. NAME is a file name or + directory name. TYPE is unused. */ + +static int +translate_unix (char *name, int type ATTRIBUTE_UNUSED) +{ + strcpy (filename_buff, name); + return 0; +} +#endif + +/* Translate a Unix syntax file specification FILESPEC into VMS syntax. + If indicators of VMS syntax found, return input string. + Return a pointer to a static buffer. */ + +static char * +to_host_file_spec (char *filespec) +{ +#ifdef VMS + if (strchr (filespec, ']') || strchr (filespec, ':')) + { + /* Looks like a VMS path. */ + return filespec; + } + else + { + + strcpy (filename_buff, filespec); + decc$to_vms (filespec, translate_unix, 1, 1); + strcpy (new_host_filespec, filename_buff); + return new_host_filespec; + } +#else + return filespec; +#endif +} + +/* Locate library LIB_NAME on the library path. */ + +static char * +locate_lib (char *lib_name) +{ + int lib_len = strlen (lib_name); + const char *exts[3]; + int i; + + if (staticp) + { + /* For static links, look for shareable image libraries last. */ + exts[0] = ".a"; + exts[1] = ".olb"; + exts[2] = ".exe"; + } + else + { + exts[0] = ".exe"; + exts[1] = ".a"; + exts[2] = ".olb"; + } + + for (i = 0; i < search_dirs_len; i++) + { + char *buf; + int l; + int j; + + l = strlen (search_dirs[i]); + buf = (char *)alloca (l + 4 + lib_len + 4 + 1); + /* Put PATH/libLIB. */ + memcpy (buf, search_dirs[i], l); + memcpy (buf + l, "/lib", 4); + l += 4; + memcpy (buf + l, lib_name, lib_len); + l += lib_len; + + /* Look for files with the extensions. */ + for (j = 0; j < 3; j++) + { + strcpy (buf + l, exts[j]); + if (is_regular_file (buf)) + return xstrdup (to_host_file_spec (buf)); + } + } + + return NULL; +} + +/* Given a library name NAME, i.e. foo, Look for libfoo.lib and then + libfoo.a in the set of directories we are allowed to search in. + May return NULL if the library can be discarded. */ + +static const char * +expand_lib (char *name) +{ + char *lib_path; + + /* Discard libc. */ + if (strcmp (name, "c") == 0) + return NULL; + + /* Discard libm. No separate library for math functions. */ + if (strcmp (name, "m") == 0) + return NULL; + + /* Search on path. */ + lib_path = locate_lib (name); + if (lib_path) + return lib_path; + + fprintf (stderr, + "Couldn't locate library: lib%s.exe, lib%s.a or lib%s.olb\n", + name, name, name); + + exit (EXIT_FAILURE); +} + +/* Preprocess the number of args P_ARGC in ARGV. + Look for special flags, etc. that must be handled first. */ + +static void +preprocess_args (int argc, char **argv) +{ + int i; + + /* Scan for -shared. */ + for (i = 1; i < argc; i++) + if (strcmp (argv[i], "-shared") == 0) + { + share = 1; + break; + } + + for (i = 1; i < argc; i++) + if (strcmp (argv[i], "-o") == 0) + { + int len; + + i++; + exefilename = lbasename (argv[i]); + exefullfilename = xstrdup (to_host_file_spec (argv[i])); + + if (share) + addarg(" /share="); + else + addarg (" /exe="); + addarg (exefullfilename); + + if (share) + { + char *ptr; + + /* Extract the basename. */ + ptr = strchr (argv[i], ']'); + if (ptr == NULL) + ptr = strchr (argv[i], ':'); + if (ptr == NULL) + ptr = strchr (argv[i], '/'); + if (ptr == NULL) + sharebasename = xstrdup (argv[i]); + else + sharebasename = xstrdup (ptr + 1); + + len = strlen (sharebasename); + if (strncasecmp (&sharebasename[len-4], ".exe", 4) == 0) + sharebasename[len - 4] = 0; + + /* Convert to uppercase. */ + for (ptr = sharebasename; *ptr; ptr++) + *ptr = TOUPPER (*ptr); + } + } + + if (exefullfilename == NULL && !share) + { + exefilename = "a_out.exe"; + exefullfilename = "a_out.exe"; + addarg (xstrdup (" /exe=a_out.exe")); + } +} + +/* Preprocess the number of args ARGC in ARGV. Look for + special flags, etc. that must be handled for the VMS linker. */ + +static void +process_args (int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) + { + if (strncmp (argv[i], "-L", 2) == 0) + { + search_dirs = XRESIZEVEC(const char *, search_dirs, + search_dirs_len + 1); + search_dirs[search_dirs_len++] = &argv[i][2]; + } + + /* -v turns on verbose option here and is passed on to gcc. */ + else if (strcmp (argv[i], "-v") == 0) + verbose++; + else if (strcmp (argv[i], "--version") == 0) + { + fprintf (stdout, "VMS Linker\n"); + exit (EXIT_SUCCESS); + } + else if (strcmp (argv[i], "--help") == 0) + { + fprintf (stdout, "VMS Linker\n"); + exit (EXIT_SUCCESS); + } + else if (strcmp (argv[i], "-g0") == 0) + addarg ("/notraceback"); + else if (strncmp (argv[i], "-g", 2) == 0) + { + addarg ("/debug"); + debug = 1; + } + else if (strcmp (argv[i], "-static") == 0) + staticp = 1; + else if (strcmp (argv[i], "-map") == 0) + { + char *buff, *ptr; + + buff = (char *) xstrdup (exefullfilename); + ptr = strrchr (buff, '.'); + if (ptr) + *ptr = 0; + + strcat (buff, ".map"); + addarg ("/map="); + addarg (buff); + addarg (".map"); + addarg ("/full"); + + free (buff); + } + else if (strcmp (argv[i], "-save-temps") == 0) + save_temps = 1; + else if (strcmp (argv[i], "--noinhibit-exec") == 0) + inhibit_exec = 0; + } +} + +#ifdef VMS +typedef struct dsc +{ + unsigned short len, mbz; + const char *adr; +} Descriptor; + +struct lst +{ + unsigned short buflen, item_code; + const void *bufaddr; + void *retlenaddr; +}; + +static struct +{ + struct lst items [1]; + unsigned int terminator; +} item_lst1; + +static struct +{ + struct lst items [2]; + unsigned int terminator; +} item_lst2; + +/* Checks if logical names are defined for setting system library path and + linker program to enable compatibility with earlier VMS versions. */ + +static void +maybe_set_link_compat (void) +{ + char lnm_buff [LNM_C_NAMLENGTH]; + unsigned int lnm_buff_len; + int status; + Descriptor tabledsc, linkdsc; + + tabledsc.adr = "LNM$JOB"; + tabledsc.len = strlen (tabledsc.adr); + tabledsc.mbz = 0; + + linkdsc.adr = "GCC_LD_SYS$LIBRARY"; + linkdsc.len = strlen (linkdsc.adr); + linkdsc.mbz = 0; + + item_lst1.items[0].buflen = LNM_C_NAMLENGTH; + item_lst1.items[0].item_code = LNM__STRING; + item_lst1.items[0].bufaddr = lnm_buff; + item_lst1.items[0].retlenaddr = &lnm_buff_len; + item_lst1.terminator = 0; + + status = SYS$TRNLNM + (0, /* attr */ + &tabledsc, /* tabnam */ + &linkdsc, /* lognam */ + 0, /* acmode */ + &item_lst1); + + /* If GCC_LD_SYS$LIBRARY is defined, redefine SYS$LIBRARY to search + the equivalence name first for system libraries, then the default + system library directory */ + + if ((status & 1) == 1) + { + unsigned char acmode = PSL_C_USER; /* Don't retain after image exit */ + const char *syslib = "SYS$SYSROOT:[SYSLIB]"; /* Default SYS$LIBRARY */ + + /* Only visible to current and child processes */ + tabledsc.adr = "LNM$PROCESS"; + tabledsc.len = strlen (tabledsc.adr); + tabledsc.mbz = 0; + + linkdsc.adr = "SYS$LIBRARY"; + linkdsc.len = strlen (linkdsc.adr); + linkdsc.mbz = 0; + + item_lst2.items[0].buflen = lnm_buff_len; + item_lst2.items[0].item_code = LNM__STRING; + item_lst2.items[0].bufaddr = lnm_buff; + item_lst2.items[0].retlenaddr = 0; + + item_lst2.items[1].buflen = strlen (syslib); + item_lst2.items[1].item_code = LNM__STRING; + item_lst2.items[1].bufaddr = syslib; + item_lst2.items[1].retlenaddr = 0; + item_lst2.terminator = 0; + + status = SYS$CRELNM + (0, /* attr */ + &tabledsc, /* tabnam */ + &linkdsc, /* lognam */ + &acmode, /* acmode */ + &item_lst2); + + } + + tabledsc.adr = "LNM$JOB"; + tabledsc.len = strlen (tabledsc.adr); + tabledsc.mbz = 0; + + linkdsc.adr = "GCC_LD_LINK"; + linkdsc.len = strlen (linkdsc.adr); + linkdsc.mbz = 0; + + item_lst1.items[0].buflen = LNM_C_NAMLENGTH; + item_lst1.items[0].item_code = LNM__STRING; + item_lst1.items[0].bufaddr = lnm_buff; + item_lst1.items[0].retlenaddr = &lnm_buff_len; + item_lst1.terminator = 0; + + status = SYS$TRNLNM + (0, /* attr */ + &tabledsc, /* tabnam */ + &linkdsc, /* lognam */ + 0, /* acmode */ + &item_lst1); + + /* If GCC_LD_LINK is defined, redefine LINK to use the equivalence name + (sometimes the LINK program version is used by VMS to determine + compatibility). */ + + if ((status & 1) == 1) + { + unsigned char acmode = PSL_C_USER; /* Don't retain after image exit. */ + + /* Only visible to current and child processes. */ + tabledsc.adr = "LNM$PROCESS"; + tabledsc.len = strlen (tabledsc.adr); + tabledsc.mbz = 0; + + linkdsc.adr = "LINK"; + linkdsc.len = strlen (linkdsc.adr); + linkdsc.mbz = 0; + + item_lst1.items[0].buflen = lnm_buff_len; + item_lst1.items[0].item_code = LNM__STRING; + item_lst1.items[0].bufaddr = lnm_buff; + item_lst1.items[0].retlenaddr = 0; + item_lst1.terminator = 0; + + status = SYS$CRELNM + (0, /* attr */ + &tabledsc, /* tabnam */ + &linkdsc, /* lognam */ + &acmode, /* acmode */ + &item_lst1); + } +} +#else +static void +maybe_set_link_compat (void) +{ +} +#endif + +/* Set environment defined executable attributes. */ + +static int +set_exe (const char *arg) +{ + char allargs [1024]; + int res; + + snprintf (allargs, sizeof (allargs), + "$@gnu:[bin]set_exe %s %s", exefullfilename, arg); + if (verbose) + printf ("%s\n", allargs); + + res = system (allargs); + if (verbose > 1) + printf ("$!status = %d\n", res); + + if ((res & 1) != 1) + { + fprintf (stderr, "ld error: popen set_exe\n"); + return 1; + } + return 0; +} + +/* The main program. Spawn the VMS linker after fixing up the Unix-like flags + and args to be what the VMS linker wants. */ + +int +main (int argc, char **argv) +{ + /* File specification for vms-dwarf2.o. */ + char *vmsdwarf2spec = 0; + + /* File specification for vms-dwarf2eh.o. */ + char *vmsdwarf2ehspec = 0; + + int i; + char cwdev[128], *devptr; + int cwdevlen; + FILE *optfile; + char *cwd, *ptr; + char *optfilename; + int status = 0; + + /* Some linker options can be set with logicals. */ + if (getenv ("GNAT$LD_NOCALL_DEBUG")) + ld_nocall_debug = 1; + if (getenv ("GNAT$LD_MKTHREADS")) + ld_mkthreads = 1; + if (getenv ("GNAT$LD_UPCALLS")) + ld_upcalls = 1; + if (getenv ("GNAT$LD_SHARED_LIBS")) + staticp = 0; + + /* Get current dir. */ +#ifdef VMS + cwd = getcwd (0, 1024, 1); +#else + cwd = getcwd (0, 1024); + strcat (cwd, "/"); +#endif + + /* Extract device part of the path. */ + devptr = strchr (cwd, ':'); + if (devptr) + cwdevlen = (devptr - cwd) + 1; + else + cwdevlen = 0; + memcpy (cwdev, cwd, cwdevlen); + cwdev [cwdevlen] = '\0'; + + maybe_set_link_compat (); + + /* Linker command starts with the command name. */ + addarg ("$ link"); + + /* Pass to find args that have to be append first. */ + preprocess_args (argc , argv); + + /* Pass to find the rest of the args. */ + process_args (argc , argv); + + if (!verbose) + addarg ("/noinform"); + + /* Create a temp file to hold args, otherwise we can easily exceed the VMS + command line length limits. */ + optfilename = (char *) xmalloc (strlen (exefilename) + 13); + strcpy (optfilename, exefilename); + ptr = strrchr (optfilename, '.'); + if (ptr) + *ptr = 0; + strcat (optfilename, ".opt_tmpfile"); + optfile = fopen (optfilename, "w"); + + /* Write out the IDENTIFICATION argument first so that it can be overridden + by an options file. */ + for (i = 1; i < argc; i++) + { + int arg_len = strlen (argv[i]); + + if (arg_len > 6 && strncasecmp (argv[i], "IDENT=", 6) == 0) + { + /* Comes from command line. If present will always appear before + --identification=... and will override. */ + break; + } + else if (arg_len > 17 + && strncasecmp (argv[i], "--identification=", 17) == 0) + { + /* Comes from pragma Ident (). */ + fprintf (optfile, "case_sensitive=yes\n"); + fprintf (optfile, "IDENTIFICATION=\"%-.15s\"\n", &argv[i][17]); + fprintf (optfile, "case_sensitive=NO\n"); + } + } + + for (i = 1; i < argc; i++) + { + int arg_len = strlen (argv[i]); + + if (strcmp (argv[i], "-o") == 0) + { + /* Already handled. */ + i++; + } + else if (arg_len > 2 && strncmp (argv[i], "-l", 2) == 0) + { + const char *libname; + + libname = expand_lib (&argv[i][2]); + if (libname != NULL) + { + int len = strlen (libname); + const char *ext; + + if (len > 4 && strcasecmp (&libname [len-4], ".exe") == 0) + ext = "/shareable"; + else + ext = "/library"; + + if (libname[0] == '[') + fprintf (optfile, "%s%s%s\n", cwdev, libname, ext); + else + fprintf (optfile, "%s%s\n", libname, ext); + } + } + else if (strcmp (argv[i], "-v" ) == 0 + || strncmp (argv[i], "-g", 2 ) == 0 + || strcmp (argv[i], "-static" ) == 0 + || strcmp (argv[i], "-map" ) == 0 + || strcmp (argv[i], "-save-temps") == 0 + || strcmp (argv[i], "--noinhibit-exec") == 0 + || (arg_len > 2 && strncmp (argv[i], "-L", 2) == 0) + || (arg_len >= 6 && strncmp (argv[i], "-share", 6) == 0)) + { + /* Already handled. */ + } + else if (strncmp (argv[i], "--opt=", 6) == 0) + fprintf (optfile, "%s\n", argv[i] + 6); + else if (arg_len > 1 && argv[i][0] == '@') + { + /* Read response file (in fact a single line of filenames). */ + FILE *atfile; + char *ptr, *ptr1; + struct stat statbuf; + char *buff; + int len; + + if (stat (&argv[i][1], &statbuf)) + { + fprintf (stderr, "Couldn't open linker response file: %s\n", + &argv[i][1]); + exit (EXIT_FAILURE); + } + + /* Read the line. */ + buff = (char *) xmalloc (statbuf.st_size + 1); + atfile = fopen (&argv[i][1], "r"); + fgets (buff, statbuf.st_size + 1, atfile); + fclose (atfile); + + /* Remove trailing \n. */ + len = strlen (buff); + if (buff [len - 1] == '\n') + { + buff [len - 1] = 0; + len--; + } + + /* Put the filenames to the opt file. */ + ptr = buff; + do + { + ptr1 = strchr (ptr, ' '); + if (ptr1) + *ptr1 = 0; + + /* Add device name if a path is present. */ + ptr = to_host_file_spec (ptr); + if (ptr[0] == '[') + fprintf (optfile, "%s%s\n", cwdev, ptr); + else + fprintf (optfile, "%s\n", ptr); + + ptr = ptr1 + 1; + } + while (ptr1); + } + else if ((argv[i][0] == '/') && (strchr (&argv[i][1], '/') == 0)) + { + /* Unix style file specs and VMS style switches look alike, + so assume an arg consisting of one and only one slash, + and that being first, is really a switch. */ + addarg (argv[i]); + } + else if (arg_len > 4 + && strncasecmp (&argv[i][arg_len-4], ".opt", 4) == 0) + { + /* Read option file. */ + FILE *optfile1; + char buff[256]; + + /* Disable __UNIX_FOPEN redefinition in case user supplied .opt + file is not stream oriented. */ + + optfile1 = (fopen) (argv[i], "r"); + if (optfile1 == 0) + { + perror (argv[i]); + status = 1; + goto cleanup_and_exit; + } + + while (fgets (buff, sizeof (buff), optfile1)) + fputs (buff, optfile); + + fclose (optfile1); + } + else if (arg_len > 7 && strncasecmp (argv[i], "GSMATCH", 7) == 0) + fprintf (optfile, "%s\n", argv[i]); + else if (arg_len > 6 && strncasecmp (argv[i], "IDENT=", 6) == 0) + { + /* Comes from command line and will override pragma. */ + fprintf (optfile, "case_sensitive=yes\n"); + fprintf (optfile, "IDENT=\"%15.15s\"\n", &argv[i][6]); + fprintf (optfile, "case_sensitive=NO\n"); + } + else if (arg_len > 17 + && strncasecmp (argv[i], "--identification=", 17) == 0) + { + /* Already handled. */ + } + else + { + /* Assume filename arg. */ + const char *file; + const char *addswitch = NULL; + char *buff; + int buff_len; + int is_cld = 0; + + file = to_host_file_spec (argv[i]); + arg_len = strlen (file); + + /* Handle shareable image libraries. */ + if (arg_len > 4 && strcasecmp (&file[arg_len - 4], ".exe") == 0) + addswitch = "/shareable"; + else if (arg_len > 4 && strcasecmp (&file[arg_len - 4], ".cld") == 0) + { + addswitch = "/shareable"; + is_cld = 1; + } + + /* Handle object libraries. */ + else if (arg_len > 2 && strcasecmp (&file[arg_len - 2], ".a") == 0) + addswitch = "/lib"; + else if (arg_len > 4 && strcasecmp (&file[arg_len - 4], ".olb") == 0) + addswitch = "/lib"; + + /* Absolutize file location. */ + if (file[0] == '[') + { + buff = (char *) xmalloc (cwdevlen + arg_len + 1); + sprintf (buff, "%s%s", cwdev, file); + } + else if (strchr (file, ':')) + { + buff = xstrdup (file); + } + else + { + buff = (char *) xmalloc (strlen (cwd) + arg_len + 1); + sprintf (buff, "%s%s", cwd, file); + } + + buff_len = strlen (buff); + + if (buff_len >= 15 + && strcasecmp (&buff[buff_len - 14], "vms-dwarf2eh.o") == 0) + { + /* Remind of it. */ + vmsdwarf2ehspec = xstrdup (buff); + } + else if (buff_len >= 13 + && strcasecmp (&buff[buff_len - 12], "vms-dwarf2.o") == 0) + { + /* Remind of it. */ + vmsdwarf2spec = xstrdup (buff); + } + else if (is_cld) + { + /* Command line definition file. */ + addarg (buff); + addarg (addswitch); + addarg (","); + } + else + { + fprintf (optfile, "%s%s\n", + buff, addswitch != NULL ? addswitch : ""); + } + free (buff); + } + } + + if (vmsdwarf2ehspec) + { + /* Sequentialize exception handling info. */ + + fprintf (optfile, "case_sensitive=yes\n"); + fprintf (optfile, "cluster=DWARF2eh,,,%s\n", vmsdwarf2ehspec); + fprintf (optfile, "collect=DWARF2eh,eh_frame\n"); + fprintf (optfile, "case_sensitive=NO\n"); + } + + if (debug && vmsdwarf2spec) + { + /* Sequentialize the debug info. */ + + fprintf (optfile, "case_sensitive=yes\n"); + fprintf (optfile, "cluster=DWARF2debug,,,%s\n", vmsdwarf2spec); + fprintf (optfile, "collect=DWARF2debug,debug_abbrev,debug_aranges,-\n"); + fprintf (optfile, " debug_frame,debug_info,debug_line,debug_loc,-\n"); + fprintf (optfile, " debug_macinfo,debug_pubnames,debug_str,-\n"); + fprintf (optfile, " debug_zzzzzz\n"); + fprintf (optfile, "case_sensitive=NO\n"); + } + + if (debug && share && vmsdwarf2spec) + { + /* Sequentialize the shared library debug info. */ + + fprintf (optfile, "case_sensitive=yes\n"); + fprintf (optfile, "symbol_vector=(-\n"); + fprintf (optfile, + "%s$DWARF2.DEBUG_ABBREV/$dwarf2.debug_abbrev=DATA,-\n", + sharebasename); + fprintf (optfile, + "%s$DWARF2.DEBUG_ARANGES/$dwarf2.debug_aranges=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_FRAME/$dwarf2.debug_frame=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_INFO/$dwarf2.debug_info=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_LINE/$dwarf2.debug_line=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_LOC/$dwarf2.debug_loc=DATA,-\n", + sharebasename); + fprintf (optfile, + "%s$DWARF2.DEBUG_MACINFO/$dwarf2.debug_macinfo=DATA,-\n", + sharebasename); + fprintf (optfile, + "%s$DWARF2.DEBUG_PUBNAMES/$dwarf2.debug_pubnames=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_STR/$dwarf2.debug_str=DATA,-\n", + sharebasename); + fprintf (optfile, "%s$DWARF2.DEBUG_ZZZZZZ/$dwarf2.debug_zzzzzz=DATA)\n", + sharebasename); + fprintf (optfile, "case_sensitive=NO\n"); + } + + fprintf (optfile, "PSECT_ATTR=LIB$INITIALIZE,GBL\n"); + fclose (optfile); + + /* Append opt file. */ + addarg (" "); + addarg (optfilename); + addarg ("/opt"); + + if (verbose) + printf ("%s\n", link_cmd); + + status = system (link_cmd); + if (verbose > 1) + printf ("$!status = %d\n", status); + + if ((status & 1) != 1) + { + status = 1; + goto cleanup_and_exit; + } + + if (debug && !share && ld_nocall_debug) + { + status = set_exe ("/flags=nocall_debug"); + if (status != 0) + goto cleanup_and_exit; + } + + if (!share && ld_mkthreads) + { + status = set_exe ("/flags=mkthreads"); + if (status != 0) + goto cleanup_and_exit; + } + + if (!share && ld_upcalls) + { + status = set_exe ("/flags=upcalls"); + if (status != 0) + goto cleanup_and_exit; + } + + status = 0; + + cleanup_and_exit: + if (!save_temps) + remove (optfilename); + + if (status == 0) + exit (EXIT_SUCCESS); + + if (exefullfilename && inhibit_exec == 1) + remove (exefullfilename); + + exit (EXIT_FAILURE); +} diff --git a/gcc-4.7/gcc/config/vms/vms-protos.h b/gcc-4.7/gcc/config/vms/vms-protos.h new file mode 100644 index 000000000..a7ca3469c --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms-protos.h @@ -0,0 +1,31 @@ +/* Definitions of target machine for GCC for VMS. + Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* vms-c.c */ +extern void vms_c_register_pragma (void); + +/* vms.c */ +void vms_patch_builtins (void); + +#ifdef TREE_CODE +extern section *vms_function_section (tree decl ATTRIBUTE_UNUSED, + enum node_frequency freq ATTRIBUTE_UNUSED, + bool startup ATTRIBUTE_UNUSED, + bool exit ATTRIBUTE_UNUSED); +#endif /* TREE_CODE */ diff --git a/gcc-4.7/gcc/config/vms/vms.c b/gcc-4.7/gcc/config/vms/vms.c new file mode 100644 index 000000000..95cc5defd --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms.c @@ -0,0 +1,194 @@ +/* Definitions of target machine GNU compiler. 32bit VMS version. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Contributed by Douglas B Rupp (rupp@gnat.com). + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "vms-protos.h" +#include "tm.h" +#include "ggc.h" + +/* Correlation of standard CRTL names with DECCRTL function names. */ + +/* Name is for a function that allocate memory. Use the 64bit version + if -mmalloc64. */ +#define VMS_CRTL_MALLOC (1 << 0) + +/* If long pointer are enabled, use _NAME64 instead. */ +#define VMS_CRTL_64 (1 << 1) + +/* Use tNAME instead. To be applied after the previous rule. */ +#define VMS_CRTL_FLOAT (1 << 2) + +/* Prepend __bsd44__ before the name. To be applied after the P64 + rule. */ +#define VMS_CRTL_BSD44 (1 << 3) + +/* Prepend x before the name for printf like functions. */ +#define VMS_CRTL_PRNTF (1 << 4) + +/* Prepend ga_ for global data. */ +#define VMS_CRTL_GLOBAL (1 << 5) + +struct vms_crtl_name +{ + /* The standard C name. */ + const char *const name; + + /* Flags to drive the translation. */ + unsigned int flags; +}; + +/* Map for the translation. */ + +static const struct vms_crtl_name vms_crtl_names[] = + { +#include "vms-crtlmap.h" + }; + +/* Number of entires in the above array. */ + +#define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names)) + +/* List of aliased identifiers. They must be persistant accross gc. */ + +static GTY(()) VEC(tree,gc) *aliases_id; + +/* Add a CRTL translation. This simply use the transparent alias + mechanism, which is platform independant and works with the + #pragma extern_prefix (which set the assembler name). */ + +static void +vms_add_crtl_xlat (const char *name, size_t nlen, + const char *id_str, size_t id_len) +{ + tree targ; + + targ = get_identifier_with_length (name, nlen); + gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (targ)); + IDENTIFIER_TRANSPARENT_ALIAS (targ) = 1; + TREE_CHAIN (targ) = get_identifier_with_length (id_str, id_len); + + VEC_safe_push (tree, gc, aliases_id, targ); + + /* printf ("vms: %s (%p) -> %.*s\n", name, targ, id_len, id_str); */ +} + +/* Do VMS specific stuff on builtins: disable the ones that are not + standard, mangle names. */ + +void +vms_patch_builtins (void) +{ + /* enum built_in_function bi; */ + unsigned int i; + + /* Fwrite on VMS is non-standard. */ + if (builtin_decl_implicit_p (BUILT_IN_FWRITE)) + set_builtin_decl_implicit_p (BUILT_IN_FWRITE, false); + + if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED)) + set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false); + + /* Define aliases for names. */ + for (i = 0; i < NBR_CRTL_NAMES; i++) + { + const struct vms_crtl_name *n = &vms_crtl_names[i]; + char res[VMS_CRTL_MAXLEN + 3 + 9 + 1 + 1]; + int rlen; + int nlen; + + /* Add the dec-c prefix. */ + memcpy (res, "decc$", 5); + rlen = 5; + + if (n->flags & VMS_CRTL_BSD44) + { + memcpy (res + rlen, "__bsd44__", 9); + rlen += 9; + } + + if (n->flags & VMS_CRTL_GLOBAL) + { + memcpy (res + rlen, "ga_", 3); + rlen += 3; + } + + if (n->flags & VMS_CRTL_FLOAT) + res[rlen++] = 't'; + + if (n->flags & VMS_CRTL_PRNTF) + res[rlen++] = 'x'; + + nlen = strlen (n->name); + memcpy (res + rlen, n->name, nlen); + + if ((n->flags & VMS_CRTL_64) == 0) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen); + else + { + char alt[VMS_CRTL_MAXLEN + 3]; + bool use_64; + + /* Add three translations: + _X32 -> X + _X64 -> _X64 + X -> X if short, _X64 if long. */ + alt[0] = '_'; + memcpy (alt + 1, n->name, nlen); + alt[1 + nlen + 0] = '3'; + alt[1 + nlen + 1] = '2'; + alt[1 + nlen + 2] = 0; + vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen); + + use_64 = (((n->flags & VMS_CRTL_64) && POINTER_SIZE == 64) + || ((n->flags & VMS_CRTL_MALLOC) + && TARGET_MALLOC64)); + if (!use_64) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen); + + res[rlen++] = '_'; + memcpy (res + rlen, n->name, nlen); + res[rlen + nlen + 0] = '6'; + res[rlen + nlen + 1] = '4'; + + if (use_64) + vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen + 2); + + alt[1 + nlen + 0] = '6'; + alt[1 + nlen + 1] = '4'; + vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen + 2); + } + } +} + +/* Always default to .text section. */ + +section * +vms_function_section (tree decl ATTRIBUTE_UNUSED, + enum node_frequency freq ATTRIBUTE_UNUSED, + bool startup ATTRIBUTE_UNUSED, + bool exit ATTRIBUTE_UNUSED) +{ + return NULL; +} + +#include "gt-vms.h" diff --git a/gcc-4.7/gcc/config/vms/vms.h b/gcc-4.7/gcc/config/vms/vms.h new file mode 100644 index 000000000..ab8f6e0dc --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms.h @@ -0,0 +1,67 @@ +/* Definitions of target machine GNU compiler. VMS common version. + Copyright (C) 2003-2009,2011 Free Software Foundation, Inc. + Contributed by Douglas B Rupp (rupp@gnat.com). + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#define TARGET_OBJECT_SUFFIX ".obj" +#define TARGET_EXECUTABLE_SUFFIX ".exe" + +#define TARGET_OS_CPP_BUILTINS() \ + do { \ + builtin_define_std ("vms"); \ + builtin_define_std ("VMS"); \ + builtin_assert ("system=vms"); \ + SUBTARGET_OS_CPP_BUILTINS(); \ + if (POINTER_SIZE == 64) \ + { \ + builtin_define ("__LONG_POINTERS=1"); \ + builtin_define ("__int64=long long"); \ + } \ + } while (0) + +extern void vms_c_register_includes (const char *, const char *, int); +#define TARGET_EXTRA_INCLUDES vms_c_register_includes + +/* Tell compiler we want to support VMS pragmas */ +#define REGISTER_TARGET_PRAGMAS() vms_c_register_pragma () + +/* By default, allow $ to be part of an identifier. */ +#define DOLLARS_IN_IDENTIFIERS 2 + +#undef TARGET_ABI_OPEN_VMS +#define TARGET_ABI_OPEN_VMS 1 + +/* "long" is 32 bits, but 64 bits for Ada. */ +#undef LONG_TYPE_SIZE +#define LONG_TYPE_SIZE 32 +#define ADA_LONG_TYPE_SIZE 64 + +/* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended. */ +#undef POINTER_SIZE +#define POINTER_SIZE 32 +#define POINTERS_EXTEND_UNSIGNED 0 + +/* Always 32 bits. */ +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +/* VMS doesn't support other sections than .text for code. */ + +#define TARGET_ASM_FUNCTION_SECTION vms_function_section diff --git a/gcc-4.7/gcc/config/vms/vms.opt b/gcc-4.7/gcc/config/vms/vms.opt new file mode 100644 index 000000000..a1713b811 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms.opt @@ -0,0 +1,31 @@ +; Copyright (C) 2009, 2011 Free Software Foundation, Inc. +; +; This file is part of GCC. +; +; GCC 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 3, or (at your option) any later +; version. +; +; GCC 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 GCC; see the file COPYING3. If not see +; <http://www.gnu.org/licenses/>. + +map +Target RejectNegative + +mmalloc64 +Target Report Mask(MALLOC64) +Malloc data into P2 space + +mdebug-main= +Target RejectNegative Joined Var(vms_debug_main) +Set name of main routine for the debugger + +mvms-return-codes +Target RejectNegative diff --git a/gcc-4.7/gcc/config/vms/vms64.h b/gcc-4.7/gcc/config/vms/vms64.h new file mode 100644 index 000000000..24249ce9b --- /dev/null +++ b/gcc-4.7/gcc/config/vms/vms64.h @@ -0,0 +1,29 @@ +/* Output variables, constants and external declarations, for GNU compiler. + Copyright (C) 2001, 2007, 2009 Free Software Foundation, Inc. + Contributed by Douglas Rupp (rupp@gnat.com). + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#undef LONG_TYPE_SIZE +#define LONG_TYPE_SIZE 64 + +#undef POINTER_SIZE +#define POINTER_SIZE 64 + +/* Defaults to "long int" */ +#undef SIZE_TYPE +#undef PTRDIFF_TYPE diff --git a/gcc-4.7/gcc/config/vms/x-vms b/gcc-4.7/gcc/config/vms/x-vms new file mode 100644 index 000000000..b232c8e68 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/x-vms @@ -0,0 +1,27 @@ +# Copyright (C) 2001, 2002, 2004, 2005, 2008, 2009 +# Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC 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 3, or (at your option) +# any later version. +# +# GCC 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 GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +LN = cp -p +LN_S = cp -p + +# Doesn't work on VMS +USE_COLLECT2= + +# There are no man pages on VMS +POD2MAN = false diff --git a/gcc-4.7/gcc/config/vms/xm-vms.h b/gcc-4.7/gcc/config/vms/xm-vms.h new file mode 100644 index 000000000..631724e92 --- /dev/null +++ b/gcc-4.7/gcc/config/vms/xm-vms.h @@ -0,0 +1,64 @@ +/* Configuration for GCC for hosting on VMS + using a Unix style C library. + Copyright (C) 1996, 1997, 2001, 2004, 2007, 2009, 2011 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* A couple of conditionals for execution machine are controlled here. */ +#ifndef VMS +#define VMS +#endif + +/* Causes exit() to be redefined to __posix_exit() and + Posix compatible failure and success codes to be used. */ +#define _POSIX_EXIT 1 + +/* Open files in stream mode if not otherwise explicitly specified. */ +#define __UNIX_FOPEN 1 + +/* Write to stdout using fputc to avoid record terminators in pipes. */ +#define __UNIX_FWRITE 1 + +#define STDC_HEADERS 1 + +#define HOST_EXECUTABLE_SUFFIX ".exe" +#define HOST_OBJECT_SUFFIX ".obj" + +#define DUMPFILE_FORMAT "_%02d_" + +#define DELETE_IF_ORDINARY(NAME,ST,VERBOSE_FLAG) \ +do \ + { \ + while (stat (NAME, &ST) >= 0 && S_ISREG (ST.st_mode)) \ + if (unlink (NAME) < 0) \ + { \ + if (VERBOSE_FLAG) \ + perror_with_name (NAME); \ + break; \ + } \ + } while (0) + +/* If 64 bit pointers are used, use 64 bit specifier. */ + +#if (defined (__INITIAL_POINTER_SIZE) && __INITIAL_POINTER_SIZE == 64) \ + || defined (__LONG_POINTERS) +#define HOST_LONG_FORMAT "ll" +#define HOST_PTR_PRINTF "%llp" +#endif + +#define STANDARD_STARTFILE_PREFIX "/gnu/lib/" |