1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 (echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
4 cat >>e${EMULATION_NAME}.c <<EOF
5 /* This file is part of GLD, the Gnu Linker.
6 Copyright 1999, 2000, 2002, 2003, 2004, 2007
7 Free Software Foundation, Inc.
9 This program 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 2 of the License, or
12 (at your option) any later version.
14 This program 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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
24 /* Need to determine load and run pages for output sections */
26 #define TARGET_IS_${EMULATION_NAME}
41 static int coff_version;
43 /* TI COFF extra command line options */
44 #define OPTION_COFF_FORMAT (300 + 1)
47 gld${EMULATION_NAME}_add_options
48 (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
49 struct option **longopts, int nrl ATTRIBUTE_UNUSED,
50 struct option **really_longopts ATTRIBUTE_UNUSED)
52 static const struct option xtra_long[] = {
54 {"format", required_argument, NULL, OPTION_COFF_FORMAT },
55 {NULL, no_argument, NULL, 0}
58 *longopts = (struct option *)
59 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
60 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
64 gld_${EMULATION_NAME}_list_options (FILE * file)
66 fprintf (file, _(" --format 0|1|2 Specify which COFF version to use\n"));
70 gld${EMULATION_NAME}_handle_option (int optc)
77 case OPTION_COFF_FORMAT:
78 if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
81 static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
82 coff_version = *optarg - '0';
84 lang_add_output_format (buf, NULL, NULL, 0);
88 einfo (_("%P%F: invalid COFF format version %s\n"), optarg);
96 gld_${EMULATION_NAME}_before_parse(void)
98 #ifndef TARGET_ /* I.e., if not generic. */
99 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
100 #endif /* not TARGET_ */
104 gld_${EMULATION_NAME}_get_script (int *isfile)
106 if test -n "$COMPILE_IN"
108 # Scripts compiled in.
110 # sed commands to quote an ld script as a C string.
116 cat >>e${EMULATION_NAME}.c <<EOF
119 if (link_info.relocatable && config.build_constructors)
120 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
121 else if (link_info.relocatable)
122 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
123 else if (!config.text_read_only)
124 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
125 else if (!config.magic_demand_paged)
126 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
128 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
133 # Scripts read from the filesystem.
135 cat >>e${EMULATION_NAME}.c <<EOF
139 if (link_info.relocatable && config.build_constructors)
140 return "ldscripts/${EMULATION_NAME}.xu";
141 else if (link_info.relocatable)
142 return "ldscripts/${EMULATION_NAME}.xr";
143 else if (!config.text_read_only)
144 return "ldscripts/${EMULATION_NAME}.xbn";
145 else if (!config.magic_demand_paged)
146 return "ldscripts/${EMULATION_NAME}.xn";
148 return "ldscripts/${EMULATION_NAME}.x";
154 cat >>e${EMULATION_NAME}.c <<EOF
155 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
157 gld_${EMULATION_NAME}_before_parse,
162 after_allocation_default,
163 set_output_arch_default,
164 ldemul_default_target,
165 before_allocation_default,
166 gld_${EMULATION_NAME}_get_script,
170 NULL, /* create output section statements */
171 NULL, /* open dynamic archive */
172 NULL, /* place orphan */
173 NULL, /* set_symbols */
174 NULL, /* parse_args */
175 gld${EMULATION_NAME}_add_options,
176 gld${EMULATION_NAME}_handle_option,
177 NULL, /* unrecognized_file */
178 gld_${EMULATION_NAME}_list_options,
179 NULL, /* recognized file */
180 NULL, /* find_potential_libraries */
181 NULL /* new_vers_pattern */