This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Patch 4/5] ld for ia64 VMS: ld part
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils Development <binutils at sourceware dot org>
- Date: Mon, 19 Mar 2012 12:28:29 +0100
- Subject: [Patch 4/5] ld for ia64 VMS: ld part
- References: <4AF8B215-7277-48D2-9476-82E4F2746404@adacore.com>
Hi,
this is the ld part.
Tristan.
ld/
2012-03-19 Tristan Gingold <gingold@adacore.com>
* scripttempl/ia64vms.sc: New file.
* emultempl/vms.em (_before_parse): Support for ia64.
(elf64-ia64-vms): New fragment for ia64.
* emulparams/elf64_ia64_vms.sh: New file.
* configure.tgt (ia64-*-*vms*): Add.
* Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64_ia64_vms.c
(eelf64_ia64_vms.c): New rule.
* Makefile.in: Regenerate.
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 37f8d1f..8069e0b 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -465,6 +465,7 @@ ALL_64_EMULATION_SOURCES = \
eelf64_aix.c \
eelf64_ia64.c \
eelf64_ia64_fbsd.c \
+ eelf64_ia64_vms.c \
eelf64_s390.c \
eelf64_sparc.c \
eelf64_sparc_fbsd.c \
@@ -1915,6 +1916,10 @@ eelf64_ia64_fbsd.c: $(srcdir)/emulparams/elf64_ia64_fbsd.sh \
$(srcdir)/emultempl/needrelax.em \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf64_ia64_fbsd "$(tdir_elf64_ia64_fbsd)"
+eelf64_ia64_vms.c: $(srcdir)/emulparams/elf64_ia64_vms.sh \
+ $(srcdir)/emultempl/vms.em \
+ $(srcdir)/scripttempl/ia64vms.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} elf64_ia64_vms "$(tdir_elf64_ia64_vms)"
eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf64_s390 "$(tdir_elf64_s390)"
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 8cd2915..1b1cd81 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -299,6 +299,7 @@ ia64-*-freebsd* | ia64-*-kfreebsd*-gnu)
targ_extra_emuls="elf64_ia64" ;;
ia64-*-netbsd*) targ_emul=elf64_ia64 ;;
ia64-*-linux*) targ_emul=elf64_ia64 ;;
+ia64-*-*vms*) targ_emul=elf64_ia64_vms ;;
ia64-*-aix*) targ_emul=elf64_aix
;;
ip2k-*-elf) targ_emul=elf32ip2k
diff --git a/ld/emulparams/elf64_ia64_vms.sh b/ld/emulparams/elf64_ia64_vms.sh
new file mode 100644
index 0000000..0688402
--- /dev/null
+++ b/ld/emulparams/elf64_ia64_vms.sh
@@ -0,0 +1,7 @@
+SCRIPT_NAME=ia64vms
+
+OUTPUT_FORMAT="elf64-ia64-vms"
+ARCH=ia64
+
+COMPILE_IN=yes
+EXTRA_EM_FILE=vms
diff --git a/ld/emultempl/vms.em b/ld/emultempl/vms.em
index 164f2e1..594b600 100644
--- a/ld/emultempl/vms.em
+++ b/ld/emultempl/vms.em
@@ -31,6 +31,10 @@ gld${EMULATION_NAME}_before_parse (void)
ldfile_set_output_arch ("${ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
input_flags.dynamic = TRUE;
config.has_shared = FALSE; /* Not yet. */
+
+ /* For ia64, harmless for alpha. */
+ link_info.emit_hash = FALSE;
+ link_info.spare_dynamic_tags = 0;
}
/* This is called before the input files are opened. We add the
@@ -166,6 +170,63 @@ gld${EMULATION_NAME}_handle_option (int optc)
EOF
+if test "$OUTPUT_FORMAT" = "elf64-ia64-vms"; then
+
+fragment <<EOF
+#include "elf-bfd.h"
+EOF
+
+source_em ${srcdir}/emultempl/elf-generic.em
+
+fragment <<EOF
+
+/* This is called after the sections have been attached to output
+ sections, but before any sizes or addresses have been set. */
+
+static void
+gld${EMULATION_NAME}_before_allocation (void)
+{
+ const struct elf_backend_data *bed;
+
+ if (!is_elf_hash_table (link_info.hash))
+ return;
+
+ bed = get_elf_backend_data (link_info.output_bfd);
+
+ /* The backend must work out the sizes of all the other dynamic
+ sections. */
+ if (elf_hash_table (&link_info)->dynamic_sections_created
+ && bed->elf_backend_size_dynamic_sections
+ && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd,
+ &link_info))
+ einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+
+ before_allocation_default ();
+}
+
+static void
+gld${EMULATION_NAME}_after_allocation (void)
+{
+ bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
+ &link_info);
+ gld${EMULATION_NAME}_map_segments (need_layout);
+}
+
+static void
+gld${EMULATION_NAME}_after_parse (void)
+{
+ link_info.relax_pass = 2;
+ after_parse_default ();
+}
+EOF
+
+LDEMUL_BEFORE_ALLOCATION=gld"$EMULATION_NAME"_before_allocation
+LDEMUL_AFTER_ALLOCATION=gld"$EMULATION_NAME"_after_allocation
+
+LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse
+source_em ${srcdir}/emultempl/needrelax.em
+fi
+
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
diff --git a/ld/scripttempl/ia64vms.sc b/ld/scripttempl/ia64vms.sc
new file mode 100644
index 0000000..b0b1c42
--- /dev/null
+++ b/ld/scripttempl/ia64vms.sc
@@ -0,0 +1,129 @@
+# Linker script for Itanium VMS systems.
+# Tristan Gingold <gingold@adacore.com>.
+
+PAGESIZE=0x10000
+BLOCKSIZE=0x200
+
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+${LIB_SEARCH_DIRS}
+ENTRY(__entry)
+
+SECTIONS
+{
+ /* RW segment. */
+ ${RELOCATING+. = ${PAGESIZE};}
+
+ \$DATA\$ ALIGN (${BLOCKSIZE}) : {
+ *(\$DATA\$ .data .data.*)
+ *(\$BSS\$ .bss)
+ }
+
+ /* Code segment. Note: name must be \$CODE\$ */
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ \$CODE\$ ALIGN (${BLOCKSIZE}) : {
+ *(\$CODE\$ .text)
+ }
+ .plt ALIGN (8) : {
+ *(.plt)
+ }
+
+ /* RO segment. */
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ /* RO initialized data. */
+ \$LITERAL\$ ALIGN (${BLOCKSIZE}) : {
+ *(\$LITERAL\$)
+ *(\$READONLY\$ .rodata)
+ *(.jcr)
+ *(.ctors)
+ *(.dtors)
+ *(.opd)
+ *(.gcc_except_table)
+
+ /* LIB$INITIALIZE stuff. */
+ *(LIB\$INITIALIZDZ) /* Start marker. */
+ *(LIB\$INITIALIZD_) /* Hi priority. */
+ *(LIB\$INITIALIZE) /* User. */
+ *(LIB\$INITIALIZE$) /* End marker. */
+ }
+
+ /* Short segment. */
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ .srodata : {
+ *(.srodata)
+ }
+ .got ALIGN (8) : {
+ *(.got)
+ }
+ .IA_64.pltoff ALIGN (16) : {
+ *(.IA_64.pltoff)
+ }
+ \$TFR\$ ALIGN (16) : {
+ /* Tranfer vector. */
+ __entry = .;
+ *(.transfer)
+ }
+
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ \$RW_SHORT\$ ALIGN (${BLOCKSIZE}) : {
+ *(.sdata .sdata.*)
+ *(.sbss)
+ }
+
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ .IA_64.unwind ALIGN (${BLOCKSIZE}) : {
+ *(.IA_64.unwind .IA_64.unwind.*)
+ }
+
+ .IA_64.unwind_info ALIGN (8) : {
+ *(.IA_64.unwind_info .IA_64.unwind_info.*)
+ }
+
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ .dynamic /* \$DYNAMIC\$ */ ALIGN (${BLOCKSIZE}) : {
+ *(.dynamic)
+ *(.vmsdynstr)
+ *(.fixups)
+ }
+
+ ${RELOCATING+. = ALIGN (${PAGESIZE});}
+
+ .dynstr : { *(.dynstr) }
+
+ .dynsym ${RELOCATING-0} : { *(.dynsym) }
+ .rela.got : { *(.rela.got) }
+ .got.plt : { *(.got.plt) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rela.IA_64.pltoff : { *(.rela.IA_64.pltoff) }
+
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .trace_info 0 : { *(.trace_info) }
+ .trace_abbrev 0 : { *(.trace_abbrev) }
+ .trace_aranges 0 : { *(.trace_aranges) }
+
+ /* DWARF 3 */
+ .debug_pubtypes 0 : { *(.debug_pubtypes) }
+ .debug_ranges 0 : { *(.debug_ranges) }
+
+ .note : { *(.vms.note) }
+
+ /DISCARD/ : { *(.note) }
+}
+EOF