summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/ld
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2008-05-29 02:29:59 +0000
committerobrien <obrien@FreeBSD.org>2008-05-29 02:29:59 +0000
commitcd5f96a9efbe194cb6e0506e727cb6d287247d69 (patch)
tree8d527b1462ba161a1cbe2165e1f019efb0c2e036 /contrib/binutils/ld
parent2e6f1b26dbf52b25a354bb58ba058fb297b526ea (diff)
downloadFreeBSD-src-cd5f96a9efbe194cb6e0506e727cb6d287247d69.zip
FreeBSD-src-cd5f96a9efbe194cb6e0506e727cb6d287247d69.tar.gz
Import of Binutils from the FSF 2.15 branch (just post-.0 release).
These bits are taken from the FSF anoncvs repo on 23-May-2004 04:41:00 UTC.
Diffstat (limited to 'contrib/binutils/ld')
-rw-r--r--contrib/binutils/ld/emulparams/elf32bmipn32-defs.sh58
-rw-r--r--contrib/binutils/ld/emulparams/elf32btsmip.sh9
-rw-r--r--contrib/binutils/ld/emulparams/elf32btsmipn32.sh15
-rw-r--r--contrib/binutils/ld/emulparams/elf32ltsmip.sh2
-rw-r--r--contrib/binutils/ld/emulparams/elf32ltsmipn32.sh4
-rw-r--r--contrib/binutils/ld/emulparams/elf32mipswindiss.sh27
-rw-r--r--contrib/binutils/ld/emulparams/elf64btsmip.sh16
-rw-r--r--contrib/binutils/ld/emulparams/elf64ltsmip.sh4
-rw-r--r--contrib/binutils/ld/emulparams/mipsbig.sh6
-rw-r--r--contrib/binutils/ld/emulparams/mipsbsd.sh7
-rw-r--r--contrib/binutils/ld/emulparams/mipsidt.sh11
-rw-r--r--contrib/binutils/ld/emulparams/mipsidtl.sh11
-rw-r--r--contrib/binutils/ld/emulparams/mipslit.sh6
-rw-r--r--contrib/binutils/ld/emulparams/mipslnews.sh9
-rw-r--r--contrib/binutils/ld/emulparams/mipspe.sh9
-rw-r--r--contrib/binutils/ld/emultempl/mipsecoff.em248
-rw-r--r--contrib/binutils/ld/emultempl/mipself.em177
-rw-r--r--contrib/binutils/ld/scripttempl/mips.sc72
-rw-r--r--contrib/binutils/ld/scripttempl/mipsbsd.sc30
19 files changed, 721 insertions, 0 deletions
diff --git a/contrib/binutils/ld/emulparams/elf32bmipn32-defs.sh b/contrib/binutils/ld/emulparams/elf32bmipn32-defs.sh
new file mode 100644
index 0000000..f7b0d08
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32bmipn32-defs.sh
@@ -0,0 +1,58 @@
+# If you change this file, please also look at files which source this one:
+# elf64bmip.sh elf64btsmip.sh elf32btsmipn32.sh elf32bmipn32.sh
+
+# This is an ELF platform.
+SCRIPT_NAME=elf
+
+# Handle both big- and little-ended 32-bit MIPS objects.
+ARCH=mips
+OUTPUT_FORMAT="elf32-bigmips"
+BIG_OUTPUT_FORMAT="elf32-bigmips"
+LITTLE_OUTPUT_FORMAT="elf32-littlemips"
+
+TEMPLATE_NAME=elf32
+
+case "$EMULATION_NAME" in
+elf32*n32*) ELFSIZE=32 ;;
+elf64*) ELFSIZE=64 ;;
+*) echo $0: unhandled emulation $EMULATION_NAME >&2; exit 1 ;;
+esac
+
+if test `echo "$host" | sed -e s/64//` = `echo "$target" | sed -e s/64//`; then
+ case " $EMULATION_LIBPATH " in
+ *" ${EMULATION_NAME} "*)
+ NATIVE=yes
+ ;;
+ esac
+fi
+
+# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+LIBPATH_SUFFIX=$ELFSIZE
+
+GENERATE_SHLIB_SCRIPT=yes
+
+TEXT_START_ADDR=0x10000000
+MAXPAGESIZE=0x100000
+ENTRY=__start
+
+# GOT-related settings.
+OTHER_GOT_SYMBOLS='
+ _gp = ALIGN(16) + 0x7ff0;
+'
+OTHER_SDATA_SECTIONS="
+ .lit8 ${RELOCATING-0} : { *(.lit8) }
+ .lit4 ${RELOCATING-0} : { *(.lit4) }
+ .srdata ${RELOCATING-0} : { *(.srdata) }
+"
+
+# Magic symbols.
+TEXT_START_SYMBOLS='_ftext = . ;'
+DATA_START_SYMBOLS='_fdata = . ;'
+OTHER_BSS_SYMBOLS='_fbss = .;'
+
+INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }"
+# Discard any .MIPS.content* or .MIPS.events* sections. The linker
+# doesn't know how to adjust them.
+OTHER_SECTIONS="/DISCARD/ : { *(.MIPS.content*) *(.MIPS.events*) }"
+
+TEXT_DYNAMIC=
diff --git a/contrib/binutils/ld/emulparams/elf32btsmip.sh b/contrib/binutils/ld/emulparams/elf32btsmip.sh
new file mode 100644
index 0000000..4c5a9ab
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32btsmip.sh
@@ -0,0 +1,9 @@
+# If you change this file, please also look at files which source this one:
+# elf32ltsmip.sh
+
+. ${srcdir}/emulparams/elf32bmip.sh
+OUTPUT_FORMAT="elf32-tradbigmips"
+BIG_OUTPUT_FORMAT="elf32-tradbigmips"
+LITTLE_OUTPUT_FORMAT="elf32-tradlittlemips"
+SHLIB_TEXT_START_ADDR=0
+ENTRY=__start
diff --git a/contrib/binutils/ld/emulparams/elf32btsmipn32.sh b/contrib/binutils/ld/emulparams/elf32btsmipn32.sh
new file mode 100644
index 0000000..5ca6797
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32btsmipn32.sh
@@ -0,0 +1,15 @@
+# If you change this file, please also look at files which source this one:
+# elf32ltsmipn32.sh
+
+. ${srcdir}/emulparams/elf32bmipn32-defs.sh
+OUTPUT_FORMAT="elf32-ntradbigmips"
+BIG_OUTPUT_FORMAT="elf32-ntradbigmips"
+LITTLE_OUTPUT_FORMAT="elf32-ntradlittlemips"
+COMMONPAGESIZE=0x1000
+
+# Magic sections.
+OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)'
+OTHER_SECTIONS='
+ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+'
diff --git a/contrib/binutils/ld/emulparams/elf32ltsmip.sh b/contrib/binutils/ld/emulparams/elf32ltsmip.sh
new file mode 100644
index 0000000..4a660f0
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32ltsmip.sh
@@ -0,0 +1,2 @@
+. ${srcdir}/emulparams/elf32btsmip.sh
+OUTPUT_FORMAT="elf32-tradlittlemips"
diff --git a/contrib/binutils/ld/emulparams/elf32ltsmipn32.sh b/contrib/binutils/ld/emulparams/elf32ltsmipn32.sh
new file mode 100644
index 0000000..276477d
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32ltsmipn32.sh
@@ -0,0 +1,4 @@
+. ${srcdir}/emulparams/elf32btsmipn32.sh
+OUTPUT_FORMAT="elf32-ntradlittlemips"
+BIG_OUTPUT_FORMAT="elf32-ntradbigmips"
+LITTLE_OUTPUT_FORMAT="elf32-ntradlittlemips"
diff --git a/contrib/binutils/ld/emulparams/elf32mipswindiss.sh b/contrib/binutils/ld/emulparams/elf32mipswindiss.sh
new file mode 100644
index 0000000..4f1148b
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf32mipswindiss.sh
@@ -0,0 +1,27 @@
+TEMPLATE_NAME=elf32
+SCRIPT_NAME=elf
+OUTPUT_FORMAT="elf32-bigmips"
+BIG_OUTPUT_FORMAT="elf32-bigmips"
+LITTLE_OUTPUT_FORMAT="elf32-littlemips"
+ARCH=mips
+MACHINE=
+EMBEDDED=yes
+MAXPAGESIZE=0x40000
+
+# The data below is taken from the windiss.dld linker script that comes with
+# the Diab linker.
+TEXT_START_ADDR=0x100000
+DATA_START_SYMBOLS='__DATA_ROM = .; __DATA_RAM = .;'
+SDATA_START_SYMBOLS='_SDA_BASE_ = .; _gp = . + 0x7ff0;'
+SDATA2_START_SYMBOLS='_SDA2_BASE_ = .;'
+EXECUTABLE_SYMBOLS='__HEAP_START = .; __SP_INIT = 0x800000; __SP_END = __SP_INIT - 0x20000; __HEAP_END = __SP_END; __DATA_END = _edata; __BSS_START = __bss_start; __BSS_END = _end; __HEAP_START = _end;'
+
+# The Diab tools use a different init/fini convention. Initialization code
+# is place in sections named ".init$NN". These sections are then concatenated
+# into the .init section. It is important that .init$00 be first and .init$99
+# be last. The other sections should be sorted, but the current linker script
+# parse does not seem to allow that with the SORT keyword in this context.
+INIT_START='*(.init$00); *(.init$0[1-9]); *(.init$[1-8][0-9]); *(.init$9[0-8])'
+INIT_END='*(.init$99)'
+FINI_START='*(.fini$00); *(.fini$0[1-9]); *(.fini$[1-8][0-9]); *(.fini$9[0-8])'
+FINI_END='*(.fini$99)'
diff --git a/contrib/binutils/ld/emulparams/elf64btsmip.sh b/contrib/binutils/ld/emulparams/elf64btsmip.sh
new file mode 100644
index 0000000..23a20c7
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf64btsmip.sh
@@ -0,0 +1,16 @@
+# If you change this file, please also look at files which source this one:
+# elf64ltsmip.sh
+
+. ${srcdir}/emulparams/elf32bmipn32-defs.sh
+OUTPUT_FORMAT="elf64-tradbigmips"
+BIG_OUTPUT_FORMAT="elf64-tradbigmips"
+LITTLE_OUTPUT_FORMAT="elf64-tradlittlemips"
+
+# Magic sections.
+OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)'
+OTHER_SECTIONS='
+ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+'
+
+TEXT_START_ADDR="0x120000000"
diff --git a/contrib/binutils/ld/emulparams/elf64ltsmip.sh b/contrib/binutils/ld/emulparams/elf64ltsmip.sh
new file mode 100644
index 0000000..efd6b7d
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/elf64ltsmip.sh
@@ -0,0 +1,4 @@
+. ${srcdir}/emulparams/elf64btsmip.sh
+OUTPUT_FORMAT="elf64-tradlittlemips"
+BIG_OUTPUT_FORMAT="elf64-tradbigmips"
+LITTLE_OUTPUT_FORMAT="elf64-tradlittlemips"
diff --git a/contrib/binutils/ld/emulparams/mipsbig.sh b/contrib/binutils/ld/emulparams/mipsbig.sh
new file mode 100644
index 0000000..9fe2953
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipsbig.sh
@@ -0,0 +1,6 @@
+SCRIPT_NAME=mips
+OUTPUT_FORMAT="ecoff-bigmips"
+BIG_OUTPUT_FORMAT="ecoff-bigmips"
+LITTLE_OUTPUT_FORMAT="ecoff-littlemips"
+TARGET_PAGE_SIZE=0x1000000
+ARCH=mips
diff --git a/contrib/binutils/ld/emulparams/mipsbsd.sh b/contrib/binutils/ld/emulparams/mipsbsd.sh
new file mode 100644
index 0000000..e8fb35b
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipsbsd.sh
@@ -0,0 +1,7 @@
+SCRIPT_NAME=mipsbsd
+OUTPUT_FORMAT="a.out-mips-little"
+BIG_OUTPUT_FORMAT="a.out-mips-big"
+LITTLE_OUTPUT_FORMAT="a.out-mips-little"
+TEXT_START_ADDR=0x1020
+TARGET_PAGE_SIZE=4096
+ARCH=mips
diff --git a/contrib/binutils/ld/emulparams/mipsidt.sh b/contrib/binutils/ld/emulparams/mipsidt.sh
new file mode 100644
index 0000000..63176f5
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipsidt.sh
@@ -0,0 +1,11 @@
+SCRIPT_NAME=mips
+OUTPUT_FORMAT="ecoff-bigmips"
+BIG_OUTPUT_FORMAT="ecoff-bigmips"
+LITTLE_OUTPUT_FORMAT="ecoff-littlemips"
+TARGET_PAGE_SIZE=0x1000000
+ARCH=mips
+ENTRY=start
+TEXT_START_ADDR=0xa0012000
+DATA_ADDR=.
+TEMPLATE_NAME=mipsecoff
+EMBEDDED=yes
diff --git a/contrib/binutils/ld/emulparams/mipsidtl.sh b/contrib/binutils/ld/emulparams/mipsidtl.sh
new file mode 100644
index 0000000..02279de
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipsidtl.sh
@@ -0,0 +1,11 @@
+SCRIPT_NAME=mips
+OUTPUT_FORMAT="ecoff-littlemips"
+BIG_OUTPUT_FORMAT="ecoff-bigmips"
+LITTLE_OUTPUT_FORMAT="ecoff-littlemips"
+TARGET_PAGE_SIZE=0x1000000
+ARCH=mips
+ENTRY=start
+TEXT_START_ADDR=0xa0012000
+DATA_ADDR=.
+TEMPLATE_NAME=mipsecoff
+EMBEDDED=yes
diff --git a/contrib/binutils/ld/emulparams/mipslit.sh b/contrib/binutils/ld/emulparams/mipslit.sh
new file mode 100644
index 0000000..acb2344
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipslit.sh
@@ -0,0 +1,6 @@
+SCRIPT_NAME=mips
+OUTPUT_FORMAT="ecoff-littlemips"
+BIG_OUTPUT_FORMAT="ecoff-bigmips"
+LITTLE_OUTPUT_FORMAT="ecoff-littlemips"
+TARGET_PAGE_SIZE=0x1000000
+ARCH=mips
diff --git a/contrib/binutils/ld/emulparams/mipslnews.sh b/contrib/binutils/ld/emulparams/mipslnews.sh
new file mode 100644
index 0000000..d0bb91c
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipslnews.sh
@@ -0,0 +1,9 @@
+SCRIPT_NAME=mips
+OUTPUT_FORMAT="ecoff-littlemips"
+BIG_OUTPUT_FORMAT="ecoff-bigmips"
+LITTLE_OUTPUT_FORMAT="ecoff-littlemips"
+TARGET_PAGE_SIZE=0x1000000
+ARCH=mips
+TEXT_START_ADDR=0x80080000
+DATA_ADDR=.
+EMBEDDED=yes
diff --git a/contrib/binutils/ld/emulparams/mipspe.sh b/contrib/binutils/ld/emulparams/mipspe.sh
new file mode 100644
index 0000000..9dd9ce7
--- /dev/null
+++ b/contrib/binutils/ld/emulparams/mipspe.sh
@@ -0,0 +1,9 @@
+ARCH=mips
+SCRIPT_NAME=pe
+OUTPUT_FORMAT="pei-mips"
+OUTPUT_ARCH="mips"
+RELOCATEABLE_OUTPUT_FORMAT="ecoff-littlemips"
+TEMPLATE_NAME=pe
+SUBSYSTEM=PE_DEF_SUBSYSTEM
+INITIAL_SYMBOL_CHAR=\"_\"
+ENTRY="_mainCRTStartup"
diff --git a/contrib/binutils/ld/emultempl/mipsecoff.em b/contrib/binutils/ld/emultempl/mipsecoff.em
new file mode 100644
index 0000000..dde33c2
--- /dev/null
+++ b/contrib/binutils/ld/emultempl/mipsecoff.em
@@ -0,0 +1,248 @@
+# This shell script emits a C file. -*- C -*-
+# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
+cat >e${EMULATION_NAME}.c <<EOF
+/* This file is is generated by a shell script. DO NOT EDIT! */
+
+/* Handle embedded relocs for MIPS.
+ Copyright 1994, 1995, 1997, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ Written by Ian Lance Taylor <ian@cygnus.com> based on generic.em.
+
+This file is part of GLD, the Gnu Linker.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#define TARGET_IS_${EMULATION_NAME}
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+
+#include "ld.h"
+#include "ldmain.h"
+#include "ldmisc.h"
+
+#include "ldexp.h"
+#include "ldlang.h"
+#include "ldfile.h"
+#include "ldemul.h"
+
+static void check_sections (bfd *, asection *, void *);
+
+static void
+gld${EMULATION_NAME}_before_parse (void)
+{
+#ifndef TARGET_ /* I.e., if not generic. */
+ ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
+#endif /* not TARGET_ */
+}
+
+/* This function is run after all the input files have been opened.
+ We create a .rel.sdata section for each input file with a non zero
+ .sdata section. The BFD backend will fill in these sections with
+ magic numbers which can be used to relocate the data section at run
+ time. This will only do the right thing if all the input files
+ have been compiled using -membedded-pic. */
+
+static void
+gld${EMULATION_NAME}_after_open (void)
+{
+ bfd *abfd;
+
+ if (! command_line.embedded_relocs
+ || link_info.relocatable)
+ return;
+
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec;
+
+ /* As first-order business, make sure that each input BFD is ECOFF. It
+ better be, as we are directly calling an ECOFF backend function. */
+ if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour)
+ einfo ("%F%B: all input objects must be ECOFF for --embedded-relocs\n");
+
+ datasec = bfd_get_section_by_name (abfd, ".sdata");
+
+ /* Note that we assume that the reloc_count field has already
+ been set up. We could call bfd_get_reloc_upper_bound, but
+ that returns the size of a memory buffer rather than a reloc
+ count. We do not want to call bfd_canonicalize_reloc,
+ because although it would always work it would force us to
+ read in the relocs into BFD canonical form, which would waste
+ a significant amount of time and memory. */
+ if (datasec != NULL && datasec->reloc_count > 0)
+ {
+ asection *relsec;
+
+ relsec = bfd_make_section (abfd, ".rel.sdata");
+ if (relsec == NULL
+ || ! bfd_set_section_flags (abfd, relsec,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY))
+ || ! bfd_set_section_alignment (abfd, relsec, 2)
+ || ! bfd_set_section_size (abfd, relsec,
+ datasec->reloc_count * 4))
+ einfo ("%F%B: can not create .rel.sdata section: %E\n");
+ }
+
+ /* Double check that all other data sections are empty, as is
+ required for embedded PIC code. */
+ bfd_map_over_sections (abfd, check_sections, datasec);
+ }
+}
+
+/* Check that of the data sections, only the .sdata section has
+ relocs. This is called via bfd_map_over_sections. */
+
+static void
+check_sections (bfd *abfd, asection *sec, void *sdatasec)
+{
+ if ((bfd_get_section_flags (abfd, sec) & SEC_CODE) == 0
+ && sec != sdatasec
+ && sec->reloc_count != 0)
+ einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n",
+ abfd, bfd_get_section_name (abfd, sec));
+}
+
+/* This function is called after the section sizes and offsets have
+ been set. If we are generating embedded relocs, it calls a special
+ BFD backend routine to do the work. */
+
+static void
+gld${EMULATION_NAME}_after_allocation (void)
+{
+ bfd *abfd;
+
+ if (! command_line.embedded_relocs
+ || link_info.relocatable)
+ return;
+
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec, *relsec;
+ char *errmsg;
+
+ datasec = bfd_get_section_by_name (abfd, ".sdata");
+
+ if (datasec == NULL || datasec->reloc_count == 0)
+ continue;
+
+ relsec = bfd_get_section_by_name (abfd, ".rel.sdata");
+ ASSERT (relsec != NULL);
+
+ if (! bfd_mips_ecoff_create_embedded_relocs (abfd, &link_info,
+ datasec, relsec,
+ &errmsg))
+ {
+ if (errmsg == NULL)
+ einfo ("%B%X: can not create runtime reloc information: %E\n",
+ abfd);
+ else
+ einfo ("%X%B: can not create runtime reloc information: %s\n",
+ abfd, errmsg);
+ }
+ }
+}
+
+static char *
+gld${EMULATION_NAME}_get_script (int *isfile)
+EOF
+
+if test -n "$COMPILE_IN"
+then
+# Scripts compiled in.
+
+# sed commands to quote an ld script as a C string.
+sc="-f stringify.sed"
+
+cat >>e${EMULATION_NAME}.c <<EOF
+{
+ *isfile = 0;
+
+ if (link_info.relocatable && config.build_constructors)
+ return
+EOF
+sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
+echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
+echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
+echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
+echo ' ; else return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
+echo '; }' >> e${EMULATION_NAME}.c
+
+else
+# Scripts read from the filesystem.
+
+cat >>e${EMULATION_NAME}.c <<EOF
+{
+ *isfile = 1;
+
+ if (link_info.relocatable && config.build_constructors)
+ return "ldscripts/${EMULATION_NAME}.xu";
+ else if (link_info.relocatable)
+ return "ldscripts/${EMULATION_NAME}.xr";
+ else if (!config.text_read_only)
+ return "ldscripts/${EMULATION_NAME}.xbn";
+ else if (!config.magic_demand_paged)
+ return "ldscripts/${EMULATION_NAME}.xn";
+ else
+ return "ldscripts/${EMULATION_NAME}.x";
+}
+EOF
+
+fi
+
+cat >>e${EMULATION_NAME}.c <<EOF
+
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
+{
+ gld${EMULATION_NAME}_before_parse,
+ syslib_default,
+ hll_default,
+ after_parse_default,
+ gld${EMULATION_NAME}_after_open,
+ gld${EMULATION_NAME}_after_allocation,
+ set_output_arch_default,
+ ldemul_default_target,
+ before_allocation_default,
+ gld${EMULATION_NAME}_get_script,
+ "${EMULATION_NAME}",
+ "${OUTPUT_FORMAT}",
+ NULL, /* finish */
+ NULL, /* create output section statements */
+ NULL, /* open dynamic archive */
+ NULL, /* place orphan */
+ NULL, /* set symbols */
+ NULL, /* parse args */
+ NULL, /* add_options */
+ NULL, /* handle_option */
+ NULL, /* unrecognized file */
+ NULL, /* list options */
+ NULL, /* recognized file */
+ NULL, /* find_potential_libraries */
+ NULL /* new_vers_pattern */
+};
+EOF
diff --git a/contrib/binutils/ld/emultempl/mipself.em b/contrib/binutils/ld/emultempl/mipself.em
new file mode 100644
index 0000000..a950fb1
--- /dev/null
+++ b/contrib/binutils/ld/emultempl/mipself.em
@@ -0,0 +1,177 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright 2002, 2003 Free Software Foundation, Inc.
+# Written by Mitch Lichtenberg <mpl@broadcom.com> and
+# Chris Demetriou <cgd@broadcom.com> based on m68kelf.em and mipsecoff.em.
+#
+# This file is part of GLD, the Gnu Linker.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+# This file is sourced from elf32.em, and defines some extra routines for m68k
+# embedded systems using ELF and for some other systems using m68k ELF. While
+# it is sourced from elf32.em for all m68k ELF configurations, here we include
+# only the features we want depending on the configuration.
+
+case ${target} in
+ mips*-*-elf)
+ echo "#define SUPPORT_EMBEDDED_RELOCS" >>e${EMULATION_NAME}.c
+ ;;
+esac
+
+cat >>e${EMULATION_NAME}.c <<EOF
+
+#ifdef SUPPORT_EMBEDDED_RELOCS
+static void mips_elf${ELFSIZE}_check_sections (bfd *, asection *, void *);
+#endif
+
+/* This function is run after all the input files have been opened. */
+
+static void
+mips_elf${ELFSIZE}_after_open (void)
+{
+ /* Call the standard elf routine. */
+ gld${EMULATION_NAME}_after_open ();
+
+#ifdef SUPPORT_EMBEDDED_RELOCS
+ if (command_line.embedded_relocs && (! link_info.relocatable))
+ {
+ bfd *abfd;
+
+ /* In the embedded relocs mode we create a .rel.sdata section for
+ each input file with a .sdata section which has has
+ relocations. The BFD backend will fill in these sections
+ with magic numbers which can be used to relocate the data
+ section at run time. */
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec;
+
+ /* As first-order business, make sure that each input BFD is
+ ELF. We need to call a special BFD backend function to
+ generate the embedded relocs, and we have that function
+ only for ELF */
+
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ einfo ("%F%B: all input objects must be ELF for --embedded-relocs\n");
+
+ if (bfd_get_arch_size (abfd) != ${ELFSIZE})
+ einfo ("%F%B: all input objects must be ${ELFSIZE}-bit ELF for --embedded-relocs\n");
+
+ datasec = bfd_get_section_by_name (abfd, ".sdata");
+
+ /* Note that we assume that the reloc_count field has already
+ been set up. We could call bfd_get_reloc_upper_bound, but
+ that returns the size of a memory buffer rather than a reloc
+ count. We do not want to call bfd_canonicalize_reloc,
+ because although it would always work it would force us to
+ read in the relocs into BFD canonical form, which would waste
+ a significant amount of time and memory. */
+
+ if (datasec != NULL && datasec->reloc_count > 0)
+ {
+ asection *relsec;
+
+ relsec = bfd_make_section (abfd, ".rel.sdata");
+ if (relsec == NULL
+ || ! bfd_set_section_flags (abfd, relsec,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY))
+ || ! bfd_set_section_alignment (abfd, relsec,
+ (${ELFSIZE} == 32) ? 2 : 3)
+ || ! bfd_set_section_size (abfd, relsec,
+ datasec->reloc_count
+ * ((${ELFSIZE} / 8) + 8)))
+ einfo ("%F%B: cannot create .rel.sdata section: %E\n");
+ }
+
+ /* Double check that all other data sections have no relocs,
+ as is required for embedded PIC code. */
+ bfd_map_over_sections (abfd, mips_elf${ELFSIZE}_check_sections,
+ datasec);
+ }
+ }
+#endif /* SUPPORT_EMBEDDED_RELOCS */
+}
+
+#ifdef SUPPORT_EMBEDDED_RELOCS
+/* Check that of the data sections, only the .sdata section has
+ relocs. This is called via bfd_map_over_sections. */
+
+static void
+mips_elf${ELFSIZE}_check_sections (bfd *abfd, asection *sec, void *sdatasec)
+{
+ if ((bfd_get_section_flags (abfd, sec) & SEC_DATA)
+ && sec != sdatasec
+ && sec->reloc_count != 0)
+ einfo ("%B%X: section %s has relocs; cannot use --embedded-relocs\n",
+ abfd, bfd_get_section_name (abfd, sec));
+}
+#endif /* SUPPORT_EMBEDDED_RELOCS */
+
+/* This function is called after the section sizes and offsets have
+ been set. If we are generating embedded relocs, it calls a special
+ BFD backend routine to do the work. */
+
+static void
+mips_elf${ELFSIZE}_after_allocation (void)
+{
+ /* Call the standard elf routine. */
+ after_allocation_default ();
+
+#ifdef SUPPORT_EMBEDDED_RELOCS
+ if (command_line.embedded_relocs && (! link_info.relocatable))
+ {
+ bfd *abfd;
+
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec, *relsec;
+ char *errmsg;
+
+ datasec = bfd_get_section_by_name (abfd, ".sdata");
+
+ if (datasec == NULL || datasec->reloc_count == 0)
+ continue;
+
+ relsec = bfd_get_section_by_name (abfd, ".rel.sdata");
+ ASSERT (relsec != NULL);
+
+ if (! bfd_mips_elf${ELFSIZE}_create_embedded_relocs (abfd,
+ &link_info,
+ datasec,
+ relsec,
+ &errmsg))
+ {
+ if (errmsg == NULL)
+ einfo ("%B%X: can not create runtime reloc information: %E\n",
+ abfd);
+ else
+ einfo ("%X%B: can not create runtime reloc information: %s\n",
+ abfd, errmsg);
+ }
+ }
+ }
+#endif /* SUPPORT_EMBEDDED_RELOCS */
+}
+
+EOF
+
+# We have our own after_open and after_allocation functions, but they call
+# the standard routines, so give them a different name.
+LDEMUL_AFTER_OPEN=mips_elf${ELFSIZE}_after_open
+LDEMUL_AFTER_ALLOCATION=mips_elf${ELFSIZE}_after_allocation
diff --git a/contrib/binutils/ld/scripttempl/mips.sc b/contrib/binutils/ld/scripttempl/mips.sc
new file mode 100644
index 0000000..d60aeed
--- /dev/null
+++ b/contrib/binutils/ld/scripttempl/mips.sc
@@ -0,0 +1,72 @@
+# Linker script for MIPS systems.
+# Ian Lance Taylor <ian@cygnus.com>.
+# These variables may be overridden by the emulation file. The
+# defaults are appropriate for a DECstation running Ultrix.
+test -z "$ENTRY" && ENTRY=__start
+
+if [ -z "$EMBEDDED" ]; then
+ test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x400000 + SIZEOF_HEADERS"
+else
+ test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x400000"
+fi
+if test "x$LD_FLAG" = "xn" -o "x$LD_FLAG" = "xN"; then
+ DATA_ADDR=.
+else
+ test -z "$DATA_ADDR" && DATA_ADDR=0x10000000
+fi
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
+ "${LITTLE_OUTPUT_FORMAT}")
+${LIB_SEARCH_DIRS}
+
+ENTRY(${ENTRY})
+
+SECTIONS
+{
+ ${RELOCATING+. = ${TEXT_START_ADDR};}
+ .text : {
+ ${RELOCATING+ _ftext = . };
+ *(.init)
+ ${RELOCATING+ eprol = .};
+ *(.text)
+ ${RELOCATING+PROVIDE (__runtime_reloc_start = .);}
+ *(.rel.sdata)
+ ${RELOCATING+PROVIDE (__runtime_reloc_stop = .);}
+ *(.fini)
+ ${RELOCATING+ etext = .};
+ ${RELOCATING+ _etext = .};
+ }
+ ${RELOCATING+. = ${DATA_ADDR};}
+ .rdata : {
+ *(.rdata)
+ }
+ ${RELOCATING+ _fdata = ALIGN(16);}
+ .data : {
+ *(.data)
+ ${CONSTRUCTING+CONSTRUCTORS}
+ }
+ ${RELOCATING+ _gp = ALIGN(16) + 0x8000;}
+ .lit8 : {
+ *(.lit8)
+ }
+ .lit4 : {
+ *(.lit4)
+ }
+ .sdata : {
+ *(.sdata)
+ }
+ ${RELOCATING+ edata = .;}
+ ${RELOCATING+ _edata = .;}
+ ${RELOCATING+ _fbss = .;}
+ .sbss : {
+ *(.sbss)
+ *(.scommon)
+ }
+ .bss : {
+ *(.bss)
+ *(COMMON)
+ }
+ ${RELOCATING+ end = .;}
+ ${RELOCATING+ _end = .;}
+}
+EOF
diff --git a/contrib/binutils/ld/scripttempl/mipsbsd.sc b/contrib/binutils/ld/scripttempl/mipsbsd.sc
new file mode 100644
index 0000000..b222b33
--- /dev/null
+++ b/contrib/binutils/ld/scripttempl/mipsbsd.sc
@@ -0,0 +1,30 @@
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
+ "${LITTLE_OUTPUT_FORMAT}")
+OUTPUT_ARCH(${ARCH})
+
+${RELOCATING+${LIB_SEARCH_DIRS}}
+SECTIONS
+{
+ ${RELOCATING+. = ${TEXT_START_ADDR};}
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ *(.text)
+ ${RELOCATING+etext = ${DATA_ALIGNMENT};}
+ }
+ ${RELOCATING+. = ${DATA_ALIGNMENT};}
+ .data :
+ {
+ *(.data)
+ ${CONSTRUCTING+CONSTRUCTORS}
+ ${RELOCATING+edata = .;}
+ }
+ .bss :
+ {
+ *(.bss)
+ *(COMMON)
+ ${RELOCATING+end = . };
+ }
+}
+EOF
OpenPOWER on IntegriCloud