2010-04-14 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Wed, 14 Apr 2010 09:27:27 +0000 (09:27 +0000)
committerTristan Gingold <gingold@adacore.com>
Wed, 14 Apr 2010 09:27:27 +0000 (09:27 +0000)
* emulparams/alphavms.sh: New file.
* emultempl/vms.em: New file.
* scripttempl/alphavms.sc: New file.
* configure.tgt (alpha*-*-*vms*): Added.
* Makefile.am (ALL_EMULATIONS): Add ealphavms.o
(ealphavms.c): New target.
* Makefile.in: Regenerate.

ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/configure.tgt
ld/emulparams/alphavms.sh [new file with mode: 0644]
ld/emultempl/vms.em [new file with mode: 0644]
ld/scripttempl/alphavms.sc [new file with mode: 0644]

index 7ef05f5c1647536aae3f90ee87a8a4aabe4d08fc..4268690d3237da2aff1ea27c44f04ff383411449 100644 (file)
@@ -1,3 +1,13 @@
+2010-04-14  Tristan Gingold  <gingold@adacore.com>
+
+       * emulparams/alphavms.sh: New file.
+       * emultempl/vms.em: New file.
+       * scripttempl/alphavms.sc: New file.
+       * configure.tgt (alpha*-*-*vms*): Added.
+       * Makefile.am (ALL_EMULATIONS): Add ealphavms.o
+       (ealphavms.c): New target.
+       * Makefile.in: Regenerate.
+
 2010-04-09  Nick Clifton  <nickc@redhat.com>
 
        * ldlang.c (wild_sort): Remove unused variable section_name.
index 010fb55a8f5403c08d45498d9ed7885463792499..54e930923a45d18c616a829f4270bd92f420fa1d 100644 (file)
@@ -118,6 +118,7 @@ ALL_EMULATIONS = \
        eaixppc.o \
        eaixrs6.o \
        ealpha.o \
+       ealphavms.o \
        earcelf.o \
        earm_epoc_pe.o \
        earm_wince_pe.o \
@@ -611,6 +612,10 @@ eaixrs6.c: $(srcdir)/emulparams/aixrs6.sh \
 ealpha.c: $(srcdir)/emulparams/alpha.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/alpha.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} alpha "$(tdir_alpha)"
+ealphavms.c: $(srcdir)/emulparams/alphavms.sh \
+  $(srcdir)/emultempl/vms.em $(srcdir)/scripttempl/alphavms.sc \
+  ${GEN_DEPENDS}
+       ${GENSCRIPTS} alphavms "$(tdir_alphavms)"
 earcelf.c: $(srcdir)/emulparams/arcelf.sh \
   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} arcelf "$(tdir_arcelf)"
index 5bbb899c7b4b8329469f6b8f78eea65a90c4dad5..12c465a409dc618f81ca6160e53fa61ec171f43f 100644 (file)
@@ -406,6 +406,7 @@ ALL_EMULATIONS = \
        eaixppc.o \
        eaixrs6.o \
        ealpha.o \
+       ealphavms.o \
        earcelf.o \
        earm_epoc_pe.o \
        earm_wince_pe.o \
@@ -924,6 +925,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixppc.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixrs6.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealpha.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ealphavms.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earcelf.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm_epoc_pe.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm_wince_pe.Po@am__quote@
@@ -1962,6 +1964,10 @@ eaixrs6.c: $(srcdir)/emulparams/aixrs6.sh \
 ealpha.c: $(srcdir)/emulparams/alpha.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/alpha.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} alpha "$(tdir_alpha)"
+ealphavms.c: $(srcdir)/emulparams/alphavms.sh \
+  $(srcdir)/emultempl/vms.em $(srcdir)/scripttempl/alphavms.sc \
+  ${GEN_DEPENDS}
+       ${GENSCRIPTS} alphavms "$(tdir_alphavms)"
 earcelf.c: $(srcdir)/emulparams/arcelf.sh \
   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} arcelf "$(tdir_arcelf)"
index c519ba757f1bb208c65727ea017387d7d17ecba2..def02871975d2eb519f481a52efb08bf5db1db08 100644 (file)
@@ -39,7 +39,8 @@ alpha*-*-osf*)                targ_emul=alpha ;;
 alpha*-*-gnu*)         targ_emul=elf64alpha ;;
 alpha*-*-netware*)     targ_emul=alpha ;;
 alpha*-*-netbsd*)      targ_emul=elf64alpha_nbsd ;;
-alpha*-*-openbsd*)     targ_emul=elf64alpha
+alpha*-*-openbsd*)     targ_emul=elf64alpha ;;
+alpha*-*-*vms*)                targ_emul=alphavms
                        ;;
 arc-*-elf*)            targ_emul=arcelf
                        ;;
diff --git a/ld/emulparams/alphavms.sh b/ld/emulparams/alphavms.sh
new file mode 100644 (file)
index 0000000..ac9b3a2
--- /dev/null
@@ -0,0 +1,7 @@
+SCRIPT_NAME=alphavms
+
+OUTPUT_FORMAT="vms-alpha"
+ARCH=alpha
+
+COMPILE_IN=yes
+EXTRA_EM_FILE=vms
\ No newline at end of file
diff --git a/ld/emultempl/vms.em b/ld/emultempl/vms.em
new file mode 100644 (file)
index 0000000..0b6b059
--- /dev/null
@@ -0,0 +1,123 @@
+# This shell script emits a C file. -*- C -*-
+#   Copyright 2010
+#   Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# This file is sourced from generic.em.
+
+fragment <<EOF
+static void
+gld${EMULATION_NAME}_before_parse (void)
+{
+  ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
+  config.dynamic_link = TRUE;
+  config.has_shared = FALSE; /* Not yet.  */
+}
+
+/* This is called before the input files are opened.  We add the
+   standard library.  */
+
+static void
+gld${EMULATION_NAME}_create_output_section_statements (void)
+{
+  lang_add_input_file ("imagelib", lang_input_file_is_l_enum, NULL);
+  lang_add_input_file ("starlet", lang_input_file_is_l_enum, NULL);
+  lang_add_input_file ("sys\$public_vectors", lang_input_file_is_l_enum, NULL);
+}
+
+/* Try to open a dynamic archive.  This is where we know that VMS
+   shared images (dynamic libraries) have an extension of .exe.  */
+
+static bfd_boolean
+gld${EMULATION_NAME}_open_dynamic_archive (const char *arch ATTRIBUTE_UNUSED,
+                                           search_dirs_type *search,
+                                           lang_input_statement_type *entry)
+{
+  char *string;
+
+  if (! entry->is_archive)
+    return FALSE;
+
+  string = (char *) xmalloc (strlen (search->name)
+                            + strlen (entry->filename)
+                            + sizeof "/.exe");
+
+  sprintf (string, "%s/%s.exe", search->name, entry->filename);
+
+  if (! ldfile_try_open_bfd (string, entry))
+    {
+      free (string);
+      return FALSE;
+    }
+
+  entry->filename = string;
+
+  return TRUE;
+}
+
+static int
+gld${EMULATION_NAME}_find_potential_libraries
+  (char *name, lang_input_statement_type *entry)
+{
+  return ldfile_open_file_search (name, entry, "", ".olb");
+}
+
+/* Place an orphan section.  We use this to put random OVR sections.
+   Much borrowed from elf32.em.  */
+
+static lang_output_section_statement_type *
+vms_place_orphan (asection *s,
+                 const char *secname ATTRIBUTE_UNUSED,
+                 int constraint ATTRIBUTE_UNUSED)
+{
+  static struct orphan_save hold_data =
+    {
+      "\$DATA\$",
+      SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA,
+      0, 0, 0, 0
+    };
+
+  /* We have nothing to say for anything other than a final link.  */
+  if (link_info.relocatable
+      || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
+    return NULL;
+
+  /* Only handle data sections.  */
+  if ((s->flags & SEC_DATA) == 0)
+    return NULL;
+
+  if (hold_data.os == NULL)
+    hold_data.os = lang_output_section_find (hold_data.name);
+
+  if (hold_data.os != NULL)
+    {
+      lang_add_section (&hold_data.os->children, s, hold_data.os);
+      return hold_data.os;
+    }
+  else
+    return NULL;
+}
+EOF
+
+LDEMUL_PLACE_ORPHAN=vms_place_orphan
+LDEMUL_BEFORE_PARSE=gld"$EMULATION_NAME"_before_parse
+LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=gld"$EMULATION_NAME"_create_output_section_statements
+LDEMUL_FIND_POTENTIAL_LIBRARIES=gld"$EMULATION_NAME"_find_potential_libraries
+LDEMUL_OPEN_DYNAMIC_ARCHIVE=gld"$EMULATION_NAME"_open_dynamic_archive
diff --git a/ld/scripttempl/alphavms.sc b/ld/scripttempl/alphavms.sc
new file mode 100644 (file)
index 0000000..ed4ec68
--- /dev/null
@@ -0,0 +1,34 @@
+# Linker script for Alpha VMS systems.
+# Tristan Gingold <gingold@adacore.com>.
+
+PAGESIZE=0x10000
+
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+${LIB_SEARCH_DIRS}
+
+SECTIONS
+{
+  ${RELOCATING+. = ${PAGESIZE};}
+
+  \$DATA\$ ALIGN (${PAGESIZE}) : {
+    *(\$DATA\$)
+    *(\$LINK\$)
+  }
+  \$BSS\$ ALIGN (${PAGESIZE}) : {
+    *(\$BSS\$)
+  }
+  \$CODE\$ ALIGN (${PAGESIZE}) : {
+    *(\$CODE\$)
+  }
+  \$LITERAL\$ ALIGN (${PAGESIZE}) : {
+    *(\$LITERAL\$)
+    *(\$READONLY\$)
+    *(\$READONLY_ADDR\$)
+  }
+
+  \$DST\$ 0 : {
+    *(\$DST\$)
+  }
+}
+EOF