| 1 | # This shell script emits a C file. -*- C -*-
|
|---|
| 2 | # It does some substitutions.
|
|---|
| 3 | cat >e${EMULATION_NAME}.c <<EOF
|
|---|
| 4 | /* Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003
|
|---|
| 5 | Free Software Foundation, Inc.
|
|---|
| 6 |
|
|---|
| 7 | This file is part of GLD, the Gnu Linker.
|
|---|
| 8 |
|
|---|
| 9 | GLD is free software; you can redistribute it and/or modify
|
|---|
| 10 | it under the terms of the GNU General Public License as published by
|
|---|
| 11 | the Free Software Foundation; either version 1, or (at your option)
|
|---|
| 12 | any later version.
|
|---|
| 13 |
|
|---|
| 14 | GLD is distributed in the hope that it will be useful,
|
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | GNU General Public License for more details.
|
|---|
| 18 |
|
|---|
| 19 | You should have received a copy of the GNU General Public License
|
|---|
| 20 | along with GLD; see the file COPYING. If not, write to the Free
|
|---|
| 21 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|---|
| 22 | 02111-1307, USA. */
|
|---|
| 23 |
|
|---|
| 24 | /*
|
|---|
| 25 | * emulate the Intels port of gld
|
|---|
| 26 | */
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | #include "bfd.h"
|
|---|
| 30 | #include "sysdep.h"
|
|---|
| 31 | #include "libiberty.h"
|
|---|
| 32 | #include "safe-ctype.h"
|
|---|
| 33 | #include "bfdlink.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "ld.h"
|
|---|
| 36 | #include "ldmisc.h"
|
|---|
| 37 | #include "ldmain.h"
|
|---|
| 38 |
|
|---|
| 39 | #include "ldexp.h"
|
|---|
| 40 | #include "ldlang.h"
|
|---|
| 41 | #include "ldfile.h"
|
|---|
| 42 | #include "ldemul.h"
|
|---|
| 43 |
|
|---|
| 44 | static void gld960_before_parse PARAMS ((void));
|
|---|
| 45 | static void gld960_set_output_arch PARAMS ((void));
|
|---|
| 46 | static char *gld960_choose_target PARAMS ((int, char **));
|
|---|
| 47 | static char *gld960_get_script PARAMS ((int *));
|
|---|
| 48 |
|
|---|
| 49 | #ifdef GNU960
|
|---|
| 50 |
|
|---|
| 51 | static void
|
|---|
| 52 | gld960_before_parse()
|
|---|
| 53 | {
|
|---|
| 54 | static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
|
|---|
| 55 | char **p;
|
|---|
| 56 | char *env ;
|
|---|
| 57 |
|
|---|
| 58 | for ( p = env_variables; *p; p++ ){
|
|---|
| 59 | env = (char *) getenv(*p);
|
|---|
| 60 | if (env) {
|
|---|
| 61 | ldfile_add_library_path (concat (env,
|
|---|
| 62 | "/lib/libcoff",
|
|---|
| 63 | (const char *) NULL),
|
|---|
| 64 | FALSE);
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 | ldfile_output_architecture = bfd_arch_i960;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | #else /* not GNU960 */
|
|---|
| 71 |
|
|---|
| 72 | static void gld960_before_parse()
|
|---|
| 73 | {
|
|---|
| 74 | char *env ;
|
|---|
| 75 | env = getenv("G960LIB");
|
|---|
| 76 | if (env) {
|
|---|
| 77 | ldfile_add_library_path(env, FALSE);
|
|---|
| 78 | }
|
|---|
| 79 | env = getenv("G960BASE");
|
|---|
| 80 | if (env)
|
|---|
| 81 | ldfile_add_library_path (concat (env, "/lib", (const char *) NULL),
|
|---|
| 82 | FALSE);
|
|---|
| 83 | ldfile_output_architecture = bfd_arch_i960;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | #endif /* GNU960 */
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | static void
|
|---|
| 90 | gld960_set_output_arch()
|
|---|
| 91 | {
|
|---|
| 92 | if (ldfile_output_machine_name != NULL
|
|---|
| 93 | && *ldfile_output_machine_name != '\0')
|
|---|
| 94 | {
|
|---|
| 95 | char *s, *s1;
|
|---|
| 96 |
|
|---|
| 97 | s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
|
|---|
| 98 | for (s1 = s; *s1 != '\0'; s1++)
|
|---|
| 99 | *s1 = TOLOWER (*s1);
|
|---|
| 100 | ldfile_set_output_arch (s);
|
|---|
| 101 | free (s);
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | set_output_arch_default ();
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | static char *
|
|---|
| 108 | gld960_choose_target (argc, argv)
|
|---|
| 109 | int argc ATTRIBUTE_UNUSED;
|
|---|
| 110 | char **argv ATTRIBUTE_UNUSED;
|
|---|
| 111 | {
|
|---|
| 112 | #ifdef GNU960
|
|---|
| 113 |
|
|---|
| 114 | output_filename = "b.out";
|
|---|
| 115 | return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
|
|---|
| 116 |
|
|---|
| 117 | #else
|
|---|
| 118 |
|
|---|
| 119 | char *from_outside = getenv(TARGET_ENVIRON);
|
|---|
| 120 | output_filename = "b.out";
|
|---|
| 121 |
|
|---|
| 122 | if (from_outside != (char *)NULL)
|
|---|
| 123 | return from_outside;
|
|---|
| 124 |
|
|---|
| 125 | return "coff-Intel-little";
|
|---|
| 126 |
|
|---|
| 127 | #endif
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | static char *
|
|---|
| 131 | gld960_get_script(isfile)
|
|---|
| 132 | int *isfile;
|
|---|
| 133 | EOF
|
|---|
| 134 |
|
|---|
| 135 | if test -n "$COMPILE_IN"
|
|---|
| 136 | then
|
|---|
| 137 | # Scripts compiled in.
|
|---|
| 138 |
|
|---|
| 139 | # sed commands to quote an ld script as a C string.
|
|---|
| 140 | sc="-f stringify.sed"
|
|---|
| 141 |
|
|---|
| 142 | cat >>e${EMULATION_NAME}.c <<EOF
|
|---|
| 143 | {
|
|---|
| 144 | *isfile = 0;
|
|---|
| 145 |
|
|---|
| 146 | if (link_info.relocateable && config.build_constructors)
|
|---|
| 147 | return
|
|---|
| 148 | EOF
|
|---|
| 149 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
|
|---|
| 150 | echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c
|
|---|
| 151 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
|
|---|
| 152 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
|
|---|
| 153 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
|
|---|
| 154 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
|
|---|
| 155 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
|
|---|
| 156 | echo ' ; else return' >> e${EMULATION_NAME}.c
|
|---|
| 157 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
|
|---|
| 158 | echo '; }' >> e${EMULATION_NAME}.c
|
|---|
| 159 |
|
|---|
| 160 | else
|
|---|
| 161 | # Scripts read from the filesystem.
|
|---|
| 162 |
|
|---|
| 163 | cat >>e${EMULATION_NAME}.c <<EOF
|
|---|
| 164 | {
|
|---|
| 165 | *isfile = 1;
|
|---|
| 166 |
|
|---|
| 167 | if (link_info.relocateable && config.build_constructors)
|
|---|
| 168 | return "ldscripts/${EMULATION_NAME}.xu";
|
|---|
| 169 | else if (link_info.relocateable)
|
|---|
| 170 | return "ldscripts/${EMULATION_NAME}.xr";
|
|---|
| 171 | else if (!config.text_read_only)
|
|---|
| 172 | return "ldscripts/${EMULATION_NAME}.xbn";
|
|---|
| 173 | else if (!config.magic_demand_paged)
|
|---|
| 174 | return "ldscripts/${EMULATION_NAME}.xn";
|
|---|
| 175 | else
|
|---|
| 176 | return "ldscripts/${EMULATION_NAME}.x";
|
|---|
| 177 | }
|
|---|
| 178 | EOF
|
|---|
| 179 |
|
|---|
| 180 | fi
|
|---|
| 181 |
|
|---|
| 182 | cat >>e${EMULATION_NAME}.c <<EOF
|
|---|
| 183 |
|
|---|
| 184 | struct ld_emulation_xfer_struct ld_gld960coff_emulation =
|
|---|
| 185 | {
|
|---|
| 186 | gld960_before_parse,
|
|---|
| 187 | syslib_default,
|
|---|
| 188 | hll_default,
|
|---|
| 189 | after_parse_default,
|
|---|
| 190 | after_open_default,
|
|---|
| 191 | after_allocation_default,
|
|---|
| 192 | gld960_set_output_arch,
|
|---|
| 193 | gld960_choose_target,
|
|---|
| 194 | before_allocation_default,
|
|---|
| 195 | gld960_get_script,
|
|---|
| 196 | "960coff",
|
|---|
| 197 | "",
|
|---|
| 198 | NULL, /* finish */
|
|---|
| 199 | NULL, /* create output section statements */
|
|---|
| 200 | NULL, /* open dynamic archive */
|
|---|
| 201 | NULL, /* place orphan */
|
|---|
| 202 | NULL, /* set symbols */
|
|---|
| 203 | NULL, /* parse args */
|
|---|
| 204 | NULL, /* add_options */
|
|---|
| 205 | NULL, /* handle_option */
|
|---|
| 206 | NULL, /* unrecognized file */
|
|---|
| 207 | NULL, /* list options */
|
|---|
| 208 | NULL, /* recognized file */
|
|---|
| 209 | NULL, /* find_potential_libraries */
|
|---|
| 210 | NULL /* new_vers_pattern */
|
|---|
| 211 | };
|
|---|
| 212 | EOF
|
|---|