diff options
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/binutils/ld/emulparams/m68kaux.sh | 8 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emulparams/m68klinux.sh | 7 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emulparams/m68kpsos.sh | 6 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emulparams/ppcmacos.sh | 4 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emulparams/sparcaout.sh | 6 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/ldcref.c | 326 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/mpw-eppcmac.c | 1224 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/scripttempl/elfmips.sc | 175 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/scripttempl/m68kaux.sc | 46 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/scripttempl/psos.sc | 61 |
10 files changed, 1863 insertions, 0 deletions
diff --git a/gnu/usr.bin/binutils/ld/emulparams/m68kaux.sh b/gnu/usr.bin/binutils/ld/emulparams/m68kaux.sh new file mode 100644 index 00000000000..19e86cc6cd1 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/m68kaux.sh @@ -0,0 +1,8 @@ +SCRIPT_NAME=m68kaux +OUTPUT_FORMAT="coff-m68k-aux" +SEGMENT_SIZE=0x40000 +TARGET_PAGE_SIZE=0x1000 +TEXT_START_ADDR="$SEGMENT_SIZE + SIZEOF_HEADERS" +NON_PAGED_TEXT_START_ADDR=SIZEOF_HEADERS +DATA_ALIGNMENT_="(. & (-$SEGMENT_SIZE | $TARGET_PAGE_SIZE-1)) + $SEGMENT_SIZE" +ARCH=m68k diff --git a/gnu/usr.bin/binutils/ld/emulparams/m68klinux.sh b/gnu/usr.bin/binutils/ld/emulparams/m68klinux.sh new file mode 100644 index 00000000000..56c3dad9bfc --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/m68klinux.sh @@ -0,0 +1,7 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-m68k-linux" +TARGET_PAGE_SIZE=0x1000 +TEXT_START_ADDR=0x1020 +NONPAGED_TEXT_START_ADDR=0 +ARCH=m68k +TEMPLATE_NAME=linux diff --git a/gnu/usr.bin/binutils/ld/emulparams/m68kpsos.sh b/gnu/usr.bin/binutils/ld/emulparams/m68kpsos.sh new file mode 100644 index 00000000000..34eb8ca549c --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/m68kpsos.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=psos +OUTPUT_FORMAT="elf32-m68k" +TEXT_START_ADDR=0x20000 +MAXPAGESIZE=0x1000 +ARCH=m68k +TEMPLATE_NAME=elf32 diff --git a/gnu/usr.bin/binutils/ld/emulparams/ppcmacos.sh b/gnu/usr.bin/binutils/ld/emulparams/ppcmacos.sh new file mode 100644 index 00000000000..b6b800c2c6c --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/ppcmacos.sh @@ -0,0 +1,4 @@ +TEMPLATE_NAME=aix +SCRIPT_NAME=aix +OUTPUT_FORMAT="xcoff-powermac" +ARCH=powerpc diff --git a/gnu/usr.bin/binutils/ld/emulparams/sparcaout.sh b/gnu/usr.bin/binutils/ld/emulparams/sparcaout.sh new file mode 100644 index 00000000000..5e01c28e57d --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/sparcaout.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-sunos-big" +TEXT_START_ADDR=0x2020 +TARGET_PAGE_SIZE=0x2000 +NONPAGED_TEXT_START_ADDR=0x2000 +ARCH=sparc diff --git a/gnu/usr.bin/binutils/ld/ldcref.c b/gnu/usr.bin/binutils/ld/ldcref.c new file mode 100644 index 00000000000..bdce17d4fd0 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/ldcref.c @@ -0,0 +1,326 @@ +/* ldcref.c -- output a cross reference table + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Ian Lance Taylor <ian@cygnus.com> + +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 holds routines that manage the cross reference table. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libiberty.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldmisc.h" + +/* We keep an instance of this structure for each reference to a + symbol from a given object. */ + +struct cref_ref +{ + /* The next reference. */ + struct cref_ref *next; + /* The object. */ + bfd *abfd; + /* True if the symbol is defined. */ + unsigned int def : 1; + /* True if the symbol is common. */ + unsigned int common : 1; + /* True if the symbol is undefined. */ + unsigned int undef : 1; +}; + +/* We keep a hash table of symbols. Each entry looks like this. */ + +struct cref_hash_entry +{ + struct bfd_hash_entry root; + /* The demangled name. */ + char *demangled; + /* References to and definitions of this symbol. */ + struct cref_ref *refs; +}; + +/* This is what the hash table looks like. */ + +struct cref_hash_table +{ + struct bfd_hash_table root; +}; + +/* Local functions. */ + +static struct bfd_hash_entry *cref_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static boolean cref_fill_array PARAMS ((struct cref_hash_entry *, PTR)); +static int cref_sort_array PARAMS ((const PTR, const PTR)); +static void output_one_cref PARAMS ((FILE *, struct cref_hash_entry *)); + +/* Look up an entry in the cref hash table. */ + +#define cref_hash_lookup(table, string, create, copy) \ + ((struct cref_hash_entry *) \ + bfd_hash_lookup (&(table)->root, (string), (create), (copy))) + +/* Traverse the cref hash table. */ + +#define cref_hash_traverse(table, func, info) \ + (bfd_hash_traverse \ + (&(table)->root, \ + (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \ + (info))) + +/* The cref hash table. */ + +static struct cref_hash_table cref_table; + +/* Whether the cref hash table has been initialized. */ + +static boolean cref_initialized; + +/* The number of symbols seen so far. */ + +static size_t cref_symcount; + +/* Create an entry in a cref hash table. */ + +static struct bfd_hash_entry * +cref_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + struct cref_hash_entry *ret = (struct cref_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == NULL) + ret = ((struct cref_hash_entry *) + bfd_hash_allocate (table, sizeof (struct cref_hash_entry))); + if (ret == NULL) + return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ + ret = ((struct cref_hash_entry *) + bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); + if (ret != NULL) + { + /* Set local fields. */ + ret->demangled = NULL; + ret->refs = NULL; + + /* Keep a count of the number of entries created in the hash + table. */ + ++cref_symcount; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Add a symbol to the cref hash table. This is called for every + symbol that is seen during the link. */ + +/*ARGSUSED*/ +void +add_cref (name, abfd, section, value) + const char *name; + bfd *abfd; + asection *section; + bfd_vma value; +{ + struct cref_hash_entry *h; + struct cref_ref *r; + + if (! cref_initialized) + { + if (! bfd_hash_table_init (&cref_table.root, cref_hash_newfunc)) + einfo ("%X%P: bfd_hash_table_init of cref table failed: %E\n"); + cref_initialized = true; + } + + h = cref_hash_lookup (&cref_table, name, true, false); + if (h == NULL) + einfo ("%X%P: cref_hash_lookup failed: %E\n"); + + for (r = h->refs; r != NULL; r = r->next) + if (r->abfd == abfd) + break; + + if (r == NULL) + { + r = (struct cref_ref *) xmalloc (sizeof *r); + r->next = h->refs; + h->refs = r; + r->abfd = abfd; + r->def = false; + r->common = false; + r->undef = false; + } + + if (bfd_is_und_section (section)) + r->undef = true; + else if (bfd_is_com_section (section)) + r->common = true; + else + r->def = true; +} + +/* Copy the addresses of the hash table entries into an array. This + is called via cref_hash_traverse. We also fill in the demangled + name. */ + +static boolean +cref_fill_array (h, data) + struct cref_hash_entry *h; + PTR data; +{ + struct cref_hash_entry ***pph = (struct cref_hash_entry ***) data; + + ASSERT (h->demangled == NULL); + h->demangled = demangle (h->root.string); + + **pph = h; + + ++*pph; + + return true; +} + +/* Sort an array of cref hash table entries by name. */ + +static int +cref_sort_array (a1, a2) + const PTR a1; + const PTR a2; +{ + const struct cref_hash_entry **p1 = (const struct cref_hash_entry **) a1; + const struct cref_hash_entry **p2 = (const struct cref_hash_entry **) a2; + + return strcmp ((*p1)->demangled, (*p2)->demangled); +} + +/* Write out the cref table. */ + +#define FILECOL (50) + +void +output_cref (fp) + FILE *fp; +{ + int len; + struct cref_hash_entry **csyms, **csym_fill, **csym, **csym_end; + + fprintf (fp, "\nCross Reference Table\n\n"); + fprintf (fp, "Symbol"); + len = sizeof "Symbol" - 1; + while (len < FILECOL) + { + putc (' ' , fp); + ++len; + } + fprintf (fp, "File\n"); + + if (! cref_initialized) + { + fprintf (fp, "No symbols\n"); + return; + } + + csyms = ((struct cref_hash_entry **) + xmalloc (cref_symcount * sizeof (*csyms))); + + csym_fill = csyms; + cref_hash_traverse (&cref_table, cref_fill_array, &csym_fill); + ASSERT (csym_fill - csyms == cref_symcount); + + qsort (csyms, cref_symcount, sizeof (*csyms), cref_sort_array); + + csym_end = csyms + cref_symcount; + for (csym = csyms; csym < csym_end; csym++) + output_one_cref (fp, *csym); +} + +/* Output one entry in the cross reference table. */ + +static void +output_one_cref (fp, h) + FILE *fp; + struct cref_hash_entry *h; +{ + int len; + struct bfd_link_hash_entry *hl; + struct cref_ref *r; + + hl = bfd_link_hash_lookup (link_info.hash, h->root.string, false, + false, true); + if (hl == NULL) + einfo ("%P: symbol `%T' missing from main hash table\n", + h->root.string); + else + { + /* If this symbol is defined in a dynamic object but never + referenced by a normal object, then don't print it. */ + if (hl->type == bfd_link_hash_defined) + { + if (hl->u.def.section->output_section == NULL) + return; + if ((hl->u.def.section->owner->flags & DYNAMIC) != 0) + { + for (r = h->refs; r != NULL; r = r->next) + if ((r->abfd->flags & DYNAMIC) == 0) + break; + if (r == NULL) + return; + } + } + } + + fprintf (fp, "%s ", h->demangled); + len = strlen (h->demangled) + 1; + + for (r = h->refs; r != NULL; r = r->next) + { + if (r->def) + { + while (len < FILECOL) + { + putc (' ', fp); + ++len; + } + finfo (fp, "%B\n", r->abfd); + len = 0; + } + } + + for (r = h->refs; r != NULL; r = r->next) + { + if (! r->def) + { + while (len < FILECOL) + { + putc (' ', fp); + ++len; + } + finfo (fp, "%B\n", r->abfd); + len = 0; + } + } + + ASSERT (len == 0); +} diff --git a/gnu/usr.bin/binutils/ld/mpw-eppcmac.c b/gnu/usr.bin/binutils/ld/mpw-eppcmac.c new file mode 100644 index 00000000000..185f3d7c01a --- /dev/null +++ b/gnu/usr.bin/binutils/ld/mpw-eppcmac.c @@ -0,0 +1,1224 @@ +/* This file is is generated by a shell script. DO NOT EDIT! */ + +/* AIX emulation code for ppcmacos + Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc. + Written by Steve Chamberlain <sac@cygnus.com> + AIX support by Ian Lance Taylor <ian@cygnus.com> + +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_ppcmacos + +#include "bfd.h" +#include "sysdep.h" +#include "libiberty.h" +#include "getopt.h" +#include "bfdlink.h" + +#include <ctype.h> + +#include "ld.h" +#include "ldmain.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldctor.h" +#include "ldgram.h" + +static void gldppcmacos_before_parse PARAMS ((void)); +static int gldppcmacos_parse_args PARAMS ((int, char **)); +static void gldppcmacos_after_open PARAMS ((void)); +static void gldppcmacos_before_allocation PARAMS ((void)); +static void gldppcmacos_read_file PARAMS ((const char *, boolean)); +static void gldppcmacos_free PARAMS ((PTR)); +static void gldppcmacos_find_relocs + PARAMS ((lang_statement_union_type *)); +static void gldppcmacos_find_exp_assignment PARAMS ((etree_type *)); +static char *gldppcmacos_get_script PARAMS ((int *isfile)); + +/* The file alignment required for each section. */ +static unsigned long file_align; + +/* The maximum size the stack is permitted to grow. This is stored in + the a.out header. */ +static unsigned long maxstack; + +/* The maximum data size. This is stored in the a.out header. */ +static unsigned long maxdata; + +/* Whether to perform garbage collection. */ +static int gc = 1; + +/* The module type to use. */ +static unsigned short modtype = ('1' << 8) | 'L'; + +/* Whether the .text section must be read-only (i.e., no relocs + permitted). */ +static int textro; + +/* Whether to implement Unix like linker semantics. */ +static int unix_ld; + +/* Structure used to hold import file list. */ + +struct filelist +{ + struct filelist *next; + const char *name; +}; + +/* List of import files. */ +static struct filelist *import_files; + +/* List of export symbols read from the export files. */ + +struct export_symbol_list +{ + struct export_symbol_list *next; + const char *name; + boolean syscall; +}; + +static struct export_symbol_list *export_symbols; + +/* This routine is called before anything else is done. */ + +static void +gldppcmacos_before_parse() +{ +#ifndef TARGET_ /* I.e., if not generic. */ + ldfile_output_architecture = bfd_arch_powerpc; +#endif /* not TARGET_ */ +} + +/* Handle AIX specific options. */ + +static int +gldppcmacos_parse_args (argc, argv) + int argc; + char **argv; +{ + int prevoptind = optind; + int prevopterr = opterr; + int indx; + int longind; + int optc; + long val; + char *end; + +#define OPTION_IGNORE (300) +#define OPTION_AUTOIMP (OPTION_IGNORE + 1) +#define OPTION_ERNOTOK (OPTION_AUTOIMP + 1) +#define OPTION_EROK (OPTION_ERNOTOK + 1) +#define OPTION_EXPORT (OPTION_EROK + 1) +#define OPTION_IMPORT (OPTION_EXPORT + 1) +#define OPTION_LOADMAP (OPTION_IMPORT + 1) +#define OPTION_MAXDATA (OPTION_LOADMAP + 1) +#define OPTION_MAXSTACK (OPTION_MAXDATA + 1) +#define OPTION_MODTYPE (OPTION_MAXSTACK + 1) +#define OPTION_NOAUTOIMP (OPTION_MODTYPE + 1) +#define OPTION_NOSTRCMPCT (OPTION_NOAUTOIMP + 1) +#define OPTION_PD (OPTION_NOSTRCMPCT + 1) +#define OPTION_PT (OPTION_PD + 1) +#define OPTION_STRCMPCT (OPTION_PT + 1) +#define OPTION_UNIX (OPTION_STRCMPCT + 1) + + static struct option longopts[] = { + {"basis", no_argument, NULL, OPTION_IGNORE}, + {"bautoimp", no_argument, NULL, OPTION_AUTOIMP}, + {"bcomprld", no_argument, NULL, OPTION_IGNORE}, + {"bcrld", no_argument, NULL, OPTION_IGNORE}, + {"bcror31", no_argument, NULL, OPTION_IGNORE}, + {"bD", required_argument, NULL, OPTION_MAXDATA}, + {"bE", required_argument, NULL, OPTION_EXPORT}, + {"bernotok", no_argument, NULL, OPTION_ERNOTOK}, + {"berok", no_argument, NULL, OPTION_EROK}, + {"berrmsg", no_argument, NULL, OPTION_IGNORE}, + {"bexport", required_argument, NULL, OPTION_EXPORT}, + {"bf", no_argument, NULL, OPTION_ERNOTOK}, + {"bgc", no_argument, &gc, 1}, + {"bh", required_argument, NULL, OPTION_IGNORE}, + {"bhalt", required_argument, NULL, OPTION_IGNORE}, + {"bI", required_argument, NULL, OPTION_IMPORT}, + {"bimport", required_argument, NULL, OPTION_IMPORT}, + {"bl", required_argument, NULL, OPTION_LOADMAP}, + {"bloadmap", required_argument, NULL, OPTION_LOADMAP}, + {"bmaxdata", required_argument, NULL, OPTION_MAXDATA}, + {"bmaxstack", required_argument, NULL, OPTION_MAXSTACK}, + {"bM", required_argument, NULL, OPTION_MODTYPE}, + {"bmodtype", required_argument, NULL, OPTION_MODTYPE}, + {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP}, + {"bnodelcsect", no_argument, NULL, OPTION_IGNORE}, + {"bnoentry", no_argument, NULL, OPTION_IGNORE}, + {"bnogc", no_argument, &gc, 0}, + {"bnso", no_argument, NULL, OPTION_NOAUTOIMP}, + {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT}, + {"bnotextro", no_argument, &textro, 0}, + {"bnro", no_argument, &textro, 0}, + {"bpD", required_argument, NULL, OPTION_PD}, + {"bpT", required_argument, NULL, OPTION_PT}, + {"bro", no_argument, &textro, 1}, + {"bS", required_argument, NULL, OPTION_MAXSTACK}, + {"bso", no_argument, NULL, OPTION_AUTOIMP}, + {"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT}, + {"btextro", no_argument, &textro, 1}, + {"static", no_argument, NULL, OPTION_NOAUTOIMP}, + {"unix", no_argument, NULL, OPTION_UNIX}, + {NULL, no_argument, NULL, 0} + }; + + /* Options supported by the AIX linker which we do not support: -f, + -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps, + -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl, + -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl, + -bnobind, -bnocomprld, -bnocrld, -bnoerrmsg, -bnoglink, + -bnoloadmap, -bnl, -bnoobjreorder, -bnoquiet, -bnoreorder, + -bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk, + -bx, -bX, -bxref. */ + + /* If the current option starts with -b, change the first : to an =. + The AIX linker uses : to separate the option from the argument; + changing it to = lets us treat it as a getopt option. */ + indx = optind; + if (indx == 0) + indx = 1; + if (indx < argc && strncmp (argv[indx], "-b", 2) == 0) + { + char *s; + + for (s = argv[indx]; *s != '\0'; s++) + { + if (*s == ':') + { + *s = '='; + break; + } + } + } + + opterr = 0; + optc = getopt_long_only (argc, argv, "-D:H:KT:z", longopts, &longind); + opterr = prevopterr; + + switch (optc) + { + default: + optind = prevoptind; + return 0; + + case 0: + /* Long option which just sets a flag. */ + break; + + case 'D': + val = strtol (optarg, &end, 0); + if (*end != '\0') + einfo ("%P: warning: ignoring invalid -D number %s\n", optarg); + else if (val != -1) + lang_section_start (".data", exp_intop (val)); + break; + + case 'H': + val = strtoul (optarg, &end, 0); + if (*end != '\0' + || (val & (val - 1)) != 0) + einfo ("%P: warning: ignoring invalid -H number %s\n", optarg); + else + file_align = val; + break; + + case 'K': + case 'z': + /* FIXME: This should use the page size for the target system. */ + file_align = 4096; + break; + + case 'T': + /* On AIX this is the same as GNU ld -Ttext. When we see -T + number, we assume the AIX option is intended. Otherwise, we + assume the usual GNU ld -T option is intended. We can't just + ignore the AIX option, because gcc passes it to the linker. */ + val = strtoul (optarg, &end, 0); + if (*end != '\0') + { + optind = prevoptind; + return 0; + } + lang_section_start (".text", exp_intop (val)); + break; + + case OPTION_IGNORE: + break; + + case OPTION_AUTOIMP: + link_info.static_link = false; + break; + + case OPTION_ERNOTOK: + force_make_executable = false; + break; + + case OPTION_EROK: + force_make_executable = true; + break; + + case OPTION_EXPORT: + gldppcmacos_read_file (optarg, false); + break; + + case OPTION_IMPORT: + { + struct filelist *n; + struct filelist **flpp; + + n = (struct filelist *) xmalloc (sizeof (struct filelist)); + n->next = NULL; + n->name = optarg; + flpp = &import_files; + while (*flpp != NULL) + flpp = &(*flpp)->next; + *flpp = n; + } + break; + + case OPTION_LOADMAP: + config.map_filename = optarg; + break; + + case OPTION_MAXDATA: + val = strtoul (optarg, &end, 0); + if (*end != '\0') + einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n", + optarg); + else + maxdata = val; + break; + + case OPTION_MAXSTACK: + val = strtoul (optarg, &end, 0); + if (*end != '\0') + einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n", + optarg); + else + maxstack = val; + break; + + case OPTION_MODTYPE: + if (*optarg == 'S') + { + link_info.shared = true; + ++optarg; + } + if (*optarg == '\0' || optarg[1] == '\0') + einfo ("%P: warning: ignoring invalid module type %s\n", optarg); + else + modtype = (*optarg << 8) | optarg[1]; + break; + + case OPTION_NOAUTOIMP: + link_info.static_link = true; + break; + + case OPTION_NOSTRCMPCT: + link_info.traditional_format = true; + break; + + case OPTION_PD: + /* This sets the page that the .data section is supposed to + start on. The offset within the page should still be the + offset within the file, so we need to build an appropriate + expression. */ + val = strtoul (optarg, &end, 0); + if (*end != '\0') + einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg); + else + { + etree_type *t; + + t = exp_binop ('+', + exp_intop (val), + exp_binop ('&', + exp_nameop (NAME, "."), + exp_intop (0xfff))); + t = exp_binop ('&', + exp_binop ('+', t, exp_intop (7)), + exp_intop (~ (bfd_vma) 7)); + lang_section_start (".data", t); + } + break; + + case OPTION_PT: + /* This set the page that the .text section is supposed to start + on. The offset within the page should still be the offset + within the file. */ + val = strtoul (optarg, &end, 0); + if (*end != '\0') + einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg); + else + { + etree_type *t; + + t = exp_binop ('+', + exp_intop (val), + exp_nameop (SIZEOF_HEADERS, NULL)); + t = exp_binop ('&', + exp_binop ('+', t, exp_intop (7)), + exp_intop (~ (bfd_vma) 7)); + lang_section_start (".text", t); + } + break; + + case OPTION_STRCMPCT: + link_info.traditional_format = false; + break; + + case OPTION_UNIX: + unix_ld = true; + break; + } + + return 1; +} + +/* This is called when an input file can not be recognized as a BFD + object or an archive. If the file starts with #!, we must treat it + as an import file. This is for AIX compatibility. */ + +static boolean +gldppcmacos_unrecognized_file (entry) + lang_input_statement_type *entry; +{ + FILE *e; + boolean ret; + + e = fopen (entry->filename, FOPEN_RT); + if (e == NULL) + return false; + + ret = false; + + if (getc (e) == '#' && getc (e) == '!') + { + struct filelist *n; + struct filelist **flpp; + + n = (struct filelist *) xmalloc (sizeof (struct filelist)); + n->next = NULL; + n->name = entry->filename; + flpp = &import_files; + while (*flpp != NULL) + flpp = &(*flpp)->next; + *flpp = n; + + ret = true; + entry->loaded = true; + } + + fclose (e); + + return ret; +} + +/* This is called after the input files have been opened. */ + +static void +gldppcmacos_after_open () +{ + boolean r; + struct set_info *p; + + /* Call ldctor_build_sets, after pretending that this is a + relocateable link. We do this because AIX requires relocation + entries for all references to symbols, even in a final + executable. Of course, we only want to do this if we are + producing an XCOFF output file. */ + r = link_info.relocateable; + if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL) + link_info.relocateable = true; + ldctor_build_sets (); + link_info.relocateable = r; + + /* For each set, record the size, so that the XCOFF backend can + output the correct csect length. */ + for (p = sets; p != (struct set_info *) NULL; p = p->next) + { + bfd_size_type size; + + /* If the symbol is defined, we may have been invoked from + collect, and the sets may already have been built, so we do + not do anything. */ + if (p->h->type == bfd_link_hash_defined + || p->h->type == bfd_link_hash_defweak) + continue; + + if (p->reloc != BFD_RELOC_CTOR) + { + /* Handle this if we need to. */ + abort (); + } + + size = (p->count + 2) * 4; + if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size)) + einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n"); + } +} + +/* This is called after the sections have been attached to output + sections, but before any sizes or addresses have been set. */ + +static void +gldppcmacos_before_allocation () +{ + struct filelist *fl; + struct export_symbol_list *el; + char *libpath; + asection *special_sections[6]; + int i; + + /* Handle the import and export files, if any. */ + for (fl = import_files; fl != NULL; fl = fl->next) + gldppcmacos_read_file (fl->name, true); + for (el = export_symbols; el != NULL; el = el->next) + { + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false); + if (h == NULL) + einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n"); + if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall)) + einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n"); + } + + /* Track down all relocations called for by the linker script (these + are typically constructor/destructor entries created by + CONSTRUCTORS) and let the backend know it will need to create + .loader relocs for them. */ + lang_for_each_statement (gldppcmacos_find_relocs); + + /* We need to build LIBPATH from the -L arguments. If any -rpath + arguments were used, though, we use -rpath instead, as a GNU + extension. */ + if (command_line.rpath != NULL) + libpath = command_line.rpath; + else if (search_head == NULL) + libpath = (char *) ""; + else + { + size_t len; + search_dirs_type *search; + + len = strlen (search_head->name); + libpath = xmalloc (len + 1); + strcpy (libpath, search_head->name); + for (search = search_head->next; search != NULL; search = search->next) + { + size_t nlen; + + nlen = strlen (search->name); + libpath = xrealloc (libpath, len + nlen + 2); + libpath[len] = ':'; + strcpy (libpath + len + 1, search->name); + len += nlen + 1; + } + } + + /* Let the XCOFF backend set up the .loader section. */ + if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath, + entry_symbol, file_align, + maxstack, maxdata, + gc && ! unix_ld ? true : false, + modtype, + textro ? true : false, + unix_ld, + special_sections)) + einfo ("%P%F: failed to set dynamic section sizes: %E\n"); + + /* Look through the special sections, and put them in the right + place in the link ordering. This is especially magic. */ + for (i = 0; i < 6; i++) + { + asection *sec; + lang_output_section_statement_type *os; + lang_statement_union_type **pls; + lang_input_section_type *is; + const char *oname; + boolean start; + + sec = special_sections[i]; + if (sec == NULL) + continue; + + /* Remove this section from the list of the output section. + This assumes we know what the script looks like. */ + is = NULL; + os = lang_output_section_find (sec->output_section->name); + if (os == NULL) + einfo ("%P%F: can't find output section %s\n", + sec->output_section->name); + for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->next) + { + if ((*pls)->header.type == lang_input_section_enum + && (*pls)->input_section.section == sec) + { + is = (lang_input_section_type *) *pls; + *pls = (*pls)->next; + break; + } + if ((*pls)->header.type == lang_wild_statement_enum) + { + lang_statement_union_type **pwls; + + for (pwls = &(*pls)->wild_statement.children.head; + *pwls != NULL; + pwls = &(*pwls)->next) + { + if ((*pwls)->header.type == lang_input_section_enum + && (*pwls)->input_section.section == sec) + { + is = (lang_input_section_type *) *pwls; + *pwls = (*pwls)->next; + break; + } + } + if (is != NULL) + break; + } + } + + if (is == NULL) + einfo ("%P%F: can't find %s in output section\n", + bfd_get_section_name (sec->owner, sec)); + + /* Now figure out where the section should go. */ + switch (i) + { + default: /* to avoid warnings */ + case 0: + /* _text */ + oname = ".text"; + start = true; + break; + case 1: + /* _etext */ + oname = ".text"; + start = false; + break; + case 2: + /* _data */ + oname = ".data"; + start = true; + break; + case 3: + /* _edata */ + oname = ".data"; + start = false; + break; + case 4: + case 5: + /* _end and end */ + oname = ".bss"; + start = false; + break; + } + + os = lang_output_section_find (oname); + + if (start) + { + is->header.next = os->children.head; + os->children.head = (lang_statement_union_type *) is; + } + else + { + is->header.next = NULL; + lang_statement_append (&os->children, + (lang_statement_union_type *) is, + &is->header.next); + } + } +} + +/* Read an import or export file. For an import file, this is called + by the before_allocation emulation routine. For an export file, + this is called by the parse_args emulation routine. */ + +static void +gldppcmacos_read_file (filename, import) + const char *filename; + boolean import; +{ + struct obstack *o; + FILE *f; + int lineno; + int c; + boolean keep; + const char *imppath; + const char *impfile; + const char *impmember; + + o = (struct obstack *) xmalloc (sizeof (struct obstack)); + obstack_specify_allocation (o, 0, 0, xmalloc, gldppcmacos_free); + + f = fopen (filename, FOPEN_RT); + if (f == NULL) + { + bfd_set_error (bfd_error_system_call); + einfo ("%F%s: %E\n", filename); + } + + keep = false; + + imppath = NULL; + impfile = NULL; + impmember = NULL; + + lineno = 0; + while ((c = getc (f)) != EOF) + { + char *s; + char *symname; + boolean syscall; + bfd_vma address; + struct bfd_link_hash_entry *h; + + if (c != '\n') + { + obstack_1grow (o, c); + continue; + } + + obstack_1grow (o, '\0'); + ++lineno; + + s = (char *) obstack_base (o); + while (isspace ((unsigned char) *s)) + ++s; + if (*s == '\0' + || *s == '*' + || (*s == '#' && s[1] == ' ') + || (! import && *s == '#' && s[1] == '!')) + { + obstack_free (o, obstack_base (o)); + continue; + } + + if (*s == '#' && s[1] == '!') + { + s += 2; + while (isspace ((unsigned char) *s)) + ++s; + if (*s == '\0') + { + imppath = NULL; + impfile = NULL; + impmember = NULL; + obstack_free (o, obstack_base (o)); + } + else if (*s == '(') + einfo ("%F%s%d: #! ([member]) is not supported in import files", + filename, lineno); + else + { + char cs; + char *file; + + (void) obstack_finish (o); + keep = true; + imppath = s; + impfile = NULL; + while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0') + { + if (*s == '/') + file = s + 1; + ++s; + } + if (file != NULL) + { + file[-1] = '\0'; + impfile = file; + if (imppath == file - 1) + imppath = "/"; + } + else + { + impfile = imppath; + imppath = ""; + } + cs = *s; + *s = '\0'; + while (isspace ((unsigned char) cs)) + { + ++s; + cs = *s; + } + if (cs != '(') + { + impmember = ""; + if (cs != '\0') + einfo ("%s:%d: warning: syntax error in import file\n", + filename, lineno); + } + else + { + ++s; + impmember = s; + while (*s != ')' && *s != '\0') + ++s; + if (*s == ')') + *s = '\0'; + else + einfo ("%s:%d: warning: syntax error in import file\n", + filename, lineno); + } + } + + continue; + } + + /* This is a symbol to be imported or exported. */ + symname = s; + syscall = false; + address = (bfd_vma) -1; + + while (! isspace ((unsigned char) *s) && *s != '\0') + ++s; + if (*s != '\0') + { + char *se; + + *s++ = '\0'; + + while (isspace ((unsigned char) *s)) + ++s; + + se = s; + while (! isspace ((unsigned char) *se) && *se != '\0') + ++se; + if (*se != '\0') + { + *se++ = '\0'; + while (isspace ((unsigned char) *se)) + ++se; + if (*se != '\0') + einfo ("%s%d: warning: syntax error in import/export file\n", + filename, lineno); + } + + if (strcasecmp (s, "svc") == 0 + || strcasecmp (s, "syscall") == 0) + syscall = true; + else + { + char *end; + + address = strtoul (s, &end, 0); + if (*end != '\0') + einfo ("%s:%d: warning: syntax error in import/export file\n", + filename, lineno); + } + } + + if (! import) + { + struct export_symbol_list *n; + + ldlang_add_undef (symname); + n = ((struct export_symbol_list *) + xmalloc (sizeof (struct export_symbol_list))); + n->next = export_symbols; + n->name = buystring (symname); + n->syscall = syscall; + export_symbols = n; + } + else + { + h = bfd_link_hash_lookup (link_info.hash, symname, false, false, + true); + if (h == NULL || h->type == bfd_link_hash_new) + { + /* We can just ignore attempts to import an unreferenced + symbol. */ + } + else + { + if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h, + address, imppath, impfile, + impmember)) + einfo ("%X%s:%d: failed to import symbol %s: %E\n", + filename, lineno, symname); + } + } + + obstack_free (o, obstack_base (o)); + } + + if (obstack_object_size (o) > 0) + { + einfo ("%s:%d: warning: ignoring unterminated last line\n", + filename, lineno); + obstack_free (o, obstack_base (o)); + } + + if (! keep) + { + obstack_free (o, NULL); + free (o); + } +} + +/* This routine saves us from worrying about declaring free. */ + +static void +gldppcmacos_free (p) + PTR p; +{ + free (p); +} + +/* This is called by the before_allocation routine via + lang_for_each_statement. It looks for relocations and assignments + to symbols. */ + +static void +gldppcmacos_find_relocs (s) + lang_statement_union_type *s; +{ + if (s->header.type == lang_reloc_statement_enum) + { + lang_reloc_statement_type *rs; + + rs = &s->reloc_statement; + if (rs->name == NULL) + einfo ("%F%P: only relocations against symbols are permitted\n"); + if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name)) + einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n"); + } + + if (s->header.type == lang_assignment_statement_enum) + gldppcmacos_find_exp_assignment (s->assignment_statement.exp); +} + +/* Look through an expression for an assignment statement. */ + +static void +gldppcmacos_find_exp_assignment (exp) + etree_type *exp; +{ + struct bfd_link_hash_entry *h; + + switch (exp->type.node_class) + { + case etree_provide: + h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst, + false, false, false); + if (h == NULL) + break; + /* Fall through. */ + case etree_assign: + if (strcmp (exp->assign.dst, ".") != 0) + { + if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info, + exp->assign.dst)) + einfo ("%P%F: failed to record assignment to %s: %E\n", + exp->assign.dst); + } + gldppcmacos_find_exp_assignment (exp->assign.src); + break; + + case etree_binary: + gldppcmacos_find_exp_assignment (exp->binary.lhs); + gldppcmacos_find_exp_assignment (exp->binary.rhs); + break; + + case etree_trinary: + gldppcmacos_find_exp_assignment (exp->trinary.cond); + gldppcmacos_find_exp_assignment (exp->trinary.lhs); + gldppcmacos_find_exp_assignment (exp->trinary.rhs); + break; + + case etree_unary: + gldppcmacos_find_exp_assignment (exp->unary.child); + break; + + default: + break; + } +} + +static char * +gldppcmacos_get_script(isfile) + int *isfile; +{ + *isfile = 0; + + if (link_info.relocateable == true && config.build_constructors == true) + return +"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ +OUTPUT_ARCH(powerpc)\n\ +ENTRY(__start)\n\ +SECTIONS\n\ +{\n\ + .pad 0 : { *(.pad) }\n\ + .text 0 : {\n\ + *(.text)\n\ + *(.pr)\n\ + *(.ro)\n\ + *(.db)\n\ + *(.gl)\n\ + *(.xo)\n\ + *(.ti)\n\ + *(.tb)\n\ + }\n\ + .data 0 : {\n\ + *(.data)\n\ + *(.rw)\n\ + *(.sv)\n\ + *(.ua)\n\ + . = ALIGN(4);\n\ + CONSTRUCTORS\n\ + *(.ds)\n\ + *(.tc0)\n\ + *(.tc)\n\ + *(.td)\n\ + }\n\ + .bss : {\n\ + *(.bss)\n\ + *(.bs)\n\ + *(.uc)\n\ + *(COMMON)\n\ + }\n\ + .loader 0 : {\n\ + *(.loader)\n\ + }\n\ + .debug 0 : {\n\ + *(.debug)\n\ + }\n\ +}\n\n" + ; else if (link_info.relocateable == true) return +"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ +OUTPUT_ARCH(powerpc)\n\ +ENTRY(__start)\n\ +SECTIONS\n\ +{\n\ + .pad 0 : { *(.pad) }\n\ + .text 0 : {\n\ + *(.text)\n\ + *(.pr)\n\ + *(.ro)\n\ + *(.db)\n\ + *(.gl)\n\ + *(.xo)\n\ + *(.ti)\n\ + *(.tb)\n\ + }\n\ + .data 0 : {\n\ + *(.data)\n\ + *(.rw)\n\ + *(.sv)\n\ + *(.ua)\n\ + . = ALIGN(4);\n\ + *(.ds)\n\ + *(.tc0)\n\ + *(.tc)\n\ + *(.td)\n\ + }\n\ + .bss : {\n\ + *(.bss)\n\ + *(.bs)\n\ + *(.uc)\n\ + *(COMMON)\n\ + }\n\ + .loader 0 : {\n\ + *(.loader)\n\ + }\n\ + .debug 0 : {\n\ + *(.debug)\n\ + }\n\ +}\n\n" + ; else if (!config.text_read_only) return +"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ +OUTPUT_ARCH(powerpc)\n\ + SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ +ENTRY(__start)\n\ +SECTIONS\n\ +{\n\ + .pad 0 : { *(.pad) }\n\ + .text : {\n\ + PROVIDE (_text = .);\n\ + *(.text)\n\ + *(.pr)\n\ + *(.ro)\n\ + *(.db)\n\ + *(.gl)\n\ + *(.xo)\n\ + *(.ti)\n\ + *(.tb)\n\ + PROVIDE (_etext = .);\n\ + }\n\ + .data 0 : {\n\ + PROVIDE (_data = .);\n\ + *(.data)\n\ + *(.rw)\n\ + *(.sv)\n\ + *(.ua)\n\ + . = ALIGN(4);\n\ + CONSTRUCTORS\n\ + *(.ds)\n\ + *(.tc0)\n\ + *(.tc)\n\ + *(.td)\n\ + PROVIDE (_edata = .);\n\ + }\n\ + .bss : {\n\ + *(.bss)\n\ + *(.bs)\n\ + *(.uc)\n\ + *(COMMON)\n\ + PROVIDE (_end = .);\n\ + PROVIDE (end = .);\n\ + }\n\ + .loader 0 : {\n\ + *(.loader)\n\ + }\n\ + .debug 0 : {\n\ + *(.debug)\n\ + }\n\ +}\n\n" + ; else if (!config.magic_demand_paged) return +"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ +OUTPUT_ARCH(powerpc)\n\ + SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ +ENTRY(__start)\n\ +SECTIONS\n\ +{\n\ + .pad 0 : { *(.pad) }\n\ + .text : {\n\ + PROVIDE (_text = .);\n\ + *(.text)\n\ + *(.pr)\n\ + *(.ro)\n\ + *(.db)\n\ + *(.gl)\n\ + *(.xo)\n\ + *(.ti)\n\ + *(.tb)\n\ + PROVIDE (_etext = .);\n\ + }\n\ + .data 0 : {\n\ + PROVIDE (_data = .);\n\ + *(.data)\n\ + *(.rw)\n\ + *(.sv)\n\ + *(.ua)\n\ + . = ALIGN(4);\n\ + CONSTRUCTORS\n\ + *(.ds)\n\ + *(.tc0)\n\ + *(.tc)\n\ + *(.td)\n\ + PROVIDE (_edata = .);\n\ + }\n\ + .bss : {\n\ + *(.bss)\n\ + *(.bs)\n\ + *(.uc)\n\ + *(COMMON)\n\ + PROVIDE (_end = .);\n\ + PROVIDE (end = .);\n\ + }\n\ + .loader 0 : {\n\ + *(.loader)\n\ + }\n\ + .debug 0 : {\n\ + *(.debug)\n\ + }\n\ +}\n\n" + ; else return +"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ +OUTPUT_ARCH(powerpc)\n\ + SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ +ENTRY(__start)\n\ +SECTIONS\n\ +{\n\ + .pad 0 : { *(.pad) }\n\ + .text : {\n\ + PROVIDE (_text = .);\n\ + *(.text)\n\ + *(.pr)\n\ + *(.ro)\n\ + *(.db)\n\ + *(.gl)\n\ + *(.xo)\n\ + *(.ti)\n\ + *(.tb)\n\ + PROVIDE (_etext = .);\n\ + }\n\ + .data 0 : {\n\ + PROVIDE (_data = .);\n\ + *(.data)\n\ + *(.rw)\n\ + *(.sv)\n\ + *(.ua)\n\ + . = ALIGN(4);\n\ + CONSTRUCTORS\n\ + *(.ds)\n\ + *(.tc0)\n\ + *(.tc)\n\ + *(.td)\n\ + PROVIDE (_edata = .);\n\ + }\n\ + .bss : {\n\ + *(.bss)\n\ + *(.bs)\n\ + *(.uc)\n\ + *(COMMON)\n\ + PROVIDE (_end = .);\n\ + PROVIDE (end = .);\n\ + }\n\ + .loader 0 : {\n\ + *(.loader)\n\ + }\n\ + .debug 0 : {\n\ + *(.debug)\n\ + }\n\ +}\n\n" +; } + +struct ld_emulation_xfer_struct ld_ppcmacos_emulation = +{ + gldppcmacos_before_parse, + syslib_default, + hll_default, + after_parse_default, + gldppcmacos_after_open, + after_allocation_default, + set_output_arch_default, + ldemul_default_target, + gldppcmacos_before_allocation, + gldppcmacos_get_script, + "ppcmacos", + "xcoff-powermac", + 0, /* finish */ + 0, /* create_output_section_statements */ + 0, /* open_dynamic_archive */ + 0, /* place_orphan */ + 0, /* set_symbols */ + gldppcmacos_parse_args, + gldppcmacos_unrecognized_file +}; diff --git a/gnu/usr.bin/binutils/ld/scripttempl/elfmips.sc b/gnu/usr.bin/binutils/ld/scripttempl/elfmips.sc new file mode 100644 index 00000000000..aed49a3354c --- /dev/null +++ b/gnu/usr.bin/binutils/ld/scripttempl/elfmips.sc @@ -0,0 +1,175 @@ +# +# Unusual variables checked by this code: +# NOP - two byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# + +# We use a start address of __start for Irix 5, _start for other +# targets. This is for compatibility with Irix 5, and with old MIPS +# ELF toolchains. +if [ -z "$ENTRY" ]; then + case "${target}" in + mips*-*-irix5*) ENTRY=__start ;; + *) ENTRY=_start ;; + esac +fi + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .reginfo ${RELOCATING-0} : { *(.reginfo) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .hash ${RELOCATING-0} : { *(.hash) } + .rel.text ${RELOCATING-0} : { *(.rel.text) } + .rela.text ${RELOCATING-0} : { *(.rela.text) } + .rel.data ${RELOCATING-0} : { *(.rel.data) } + .rela.data ${RELOCATING-0} : { *(.rela.data) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + .rodata ${RELOCATING-0} : { *(.rodata) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + .text ${RELOCATING-0} : + { + ${CREATE_SHLIB-${RELOCATING+${TEXT_START_SYMBOLS}}} + *(.text) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =${NOP-0} + ${CREATE_SHLIB-${RELOCATING+_etext = .;}} + ${CREATE_SHLIB-${RELOCATING+PROVIDE (etext = .);}} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. It would + be more correct to do this: + ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + + ((ALIGN(8) + ${MAXPAGESIZE} - ALIGN(${MAXPAGESIZE})) + & (${MAXPAGESIZE} - 1)};} + The current expression does not correctly handle the case of a + text segment ending precisely at the end of a page; it causes the + data segment to skip a page. The above expression does not have + this problem, but it will currently (2/95) cause BFD to allocate + a single segment, combining both text and data, for this case. + This will prevent the text segment from being shared among + multiple executions of the program; I think that is more + important than losing a page of the virtual address space (note + that no actual memory is lost; the page which is skipped can not + be referenced). */ + ${CREATE_SHLIB-${RELOCATING+. += ${DATA_ADDR} - ${TEXT_START_ADDR};}} + ${CREATE_SHLIB+${RELOCATING+. += 0x10000;}} + .data ${RELOCATING-0} : + { + ${CREATE_SHLIB-${RELOCATING+${DATA_START_SYMBOLS}}} + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + .ctors ${RELOCATING-0} : { *(.ctors) } + .dtors ${RELOCATING-0} : { *(.dtors) } + ${RELOCATING+${OTHER_GOT_SYMBOLS}} + .got ${RELOCATING-0} : + { + *(.got.plt) *(.got) + } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : { *(.sdata) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + ${CREATE_SHLIB-${RELOCATING+_edata = .;}} + ${CREATE_SHLIB-${RELOCATING+PROVIDE (edata = .);}} + ${CREATE_SHLIB-${RELOCATING+__bss_start = .;}} + ${CREATE_SHLIB-${RELOCATING+${OTHER_BSS_SYMBOLS}}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + ${CREATE_SHLIB-${RELOCATING+_end = . ;}} + ${CREATE_SHLIB-${RELOCATING+PROVIDE (end = .);}} + + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + + /* DWARF debug sections. + Symbols in the .debug DWARF section are relative to the beginning of the + section so we begin .debug at 0. It's not clear yet what needs to happen + for the others. */ + .debug 0 : { *(.debug) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .line 0 : { *(.line) } + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/gnu/usr.bin/binutils/ld/scripttempl/m68kaux.sc b/gnu/usr.bin/binutils/ld/scripttempl/m68kaux.sc new file mode 100644 index 00000000000..404280e1272 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/scripttempl/m68kaux.sc @@ -0,0 +1,46 @@ +# Linker script for A/UX. +test -z "$ENTRY" && ENTRY=_start +INIT='.init : { *(.init) }' +FINI='.fini : { *(.fini) }' +CTORS='.ctors : { *(.ctors) }' +DTORS='.dtors : { *(.dtors) }' + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ $TEXT_START_ADDR} : { + ${RELOCATING+ *(.init)} + ${RELOCATING+ *(.fini)} + *(.text) + ${RELOCATING+ . = ALIGN(4);} + ${RELOCATING+ *(.ctors)} + ${RELOCATING+ *(.dtors)} + ${RELOCATING+ etext = .;} + ${RELOCATING+ _etext = .;} + } =0x4E714E71 + .data ${RELOCATING+ $DATA_ALIGNMENT} : { + *(.data) + ${RELOCATING+ edata = .;} + ${RELOCATING+ _edata = .;} + } + .bss : { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .;} + ${RELOCATING+ _end = .;} + } + ${RELOCATING- ${INIT}} + ${RELOCATING- ${FINI}} + ${RELOCATING- ${CTORS}} + ${RELOCATING- ${DTORS}} + + .comment 0 ${RELOCATING+(NOLOAD)} : { [ .comment ] [ .ident ] } + .stab 0 ${RELOCATING+(NOLOAD)} : { [ .stab ] } + .stabstr 0 ${RELOCATING+(NOLOAD)} : { [ .stabstr ] } +} +EOF diff --git a/gnu/usr.bin/binutils/ld/scripttempl/psos.sc b/gnu/usr.bin/binutils/ld/scripttempl/psos.sc new file mode 100644 index 00000000000..ab8c6c7e3c8 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/scripttempl/psos.sc @@ -0,0 +1,61 @@ +cat <<EOF +OUTPUT_FORMAT(${OUTPUT_FORMAT}) +OUTPUT_ARCH(${ARCH}) +${RELOCATING+${LIB_SEARCH_DIRS}} + +SECTIONS +{ + .text ${RELOCATING:-0} ${RELOCATING+${TEXT_START_ADDR}} : { + ${RELOCATING+ start = DEFINED(_START) ? _START : DEFINED(_start) ? _start : .;} + ${RELOCATING+ PROVIDE(__text = .);} + *(.text); + *(code); + *(const); + *(strings); + *(pSOS); + *(pROBE); + *(pNA); + *(pHILE); + *(pREPC); + *(pRPC); + ${CONSTRUCTING+ ___CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___CTOR_END__ = .;} + ${CONSTRUCTING+ ___DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2);} + ${CONSTRUCTING+ *(.dtors);} + ${CONSTRUCTING+ LONG(0);} + ${CONSTRUCTING+ ___DTOR_END__ = .;} + ${RELOCATING+ PROVIDE(__etext = .);} + ${RELOCATING+ PROVIDE(_etext = .);} + } + .data ${RELOCATING:-0} : ${RELOCATING+ AT(ADDR(.text) + SIZEOF(.text))} { + ${RELOCATING+ PROVIDE(__data = .);} + *(.data); + *(vars); + ${RELOCATING+ PROVIDE(__edata = .);} + ${RELOCATING+ PROVIDE(_edata = .);} + } + .bss ${RELOCATING:-0} : + { + ${RELOCATING+ PROVIDE(__bss = .);} + *(.bss); + *(zerovars); + *(COMMON); + ${RELOCATING+ PROVIDE(__ebss = .);} + ${RELOCATING+ PROVIDE(__end = .);} + ${RELOCATING+ PROVIDE(_end = .);} + ${RELOCATING+ PROVIDE(_FreeMemStart = .);} + } + .stab 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab); + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr); + } +} +EOF |