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 ;-)
5 /* This file is part of GLD, the Gnu Linker.
6 Copyright (C) 1999-2018 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
26 /* Need to determine load and run pages for output sections */
28 #define TARGET_IS_${EMULATION_NAME}
43 static int coff_version;
45 /* TI COFF extra command line options */
46 #define OPTION_COFF_FORMAT (300 + 1)
49 gld${EMULATION_NAME}_add_options
50 (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
51 struct option **longopts, int nrl ATTRIBUTE_UNUSED,
52 struct option **really_longopts ATTRIBUTE_UNUSED)
54 static const struct option xtra_long[] = {
56 {"format", required_argument, NULL, OPTION_COFF_FORMAT },
57 {NULL, no_argument, NULL, 0}
60 *longopts = (struct option *)
61 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
62 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
66 gld_${EMULATION_NAME}_list_options (FILE * file)
68 fprintf (file, _(" --format 0|1|2 Specify which COFF version to use\n"));
72 gld${EMULATION_NAME}_handle_option (int optc)
79 case OPTION_COFF_FORMAT:
80 if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
83 static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
84 coff_version = *optarg - '0';
86 lang_add_output_format (buf, NULL, NULL, 0);
90 einfo (_("%P%F: invalid COFF format version %s\n"), optarg);
98 gld_${EMULATION_NAME}_before_parse(void)
100 #ifndef TARGET_ /* I.e., if not generic. */
101 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
102 #endif /* not TARGET_ */
106 gld_${EMULATION_NAME}_get_script (int *isfile)
108 if test x"$COMPILE_IN" = xyes
110 # Scripts compiled in.
112 # sed commands to quote an ld script as a C string.
121 if (bfd_link_relocatable (&link_info) && config.build_constructors)
122 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
123 else if (bfd_link_relocatable (&link_info))
124 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
125 else if (!config.text_read_only)
126 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
127 else if (!config.magic_demand_paged)
128 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
130 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
135 # Scripts read from the filesystem.
141 if (bfd_link_relocatable (&link_info) && config.build_constructors)
142 return "ldscripts/${EMULATION_NAME}.xu";
143 else if (bfd_link_relocatable (&link_info))
144 return "ldscripts/${EMULATION_NAME}.xr";
145 else if (!config.text_read_only)
146 return "ldscripts/${EMULATION_NAME}.xbn";
147 else if (!config.magic_demand_paged)
148 return "ldscripts/${EMULATION_NAME}.xn";
150 return "ldscripts/${EMULATION_NAME}.x";
157 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
159 gld_${EMULATION_NAME}_before_parse,
164 after_check_relocs_default,
165 after_allocation_default,
166 set_output_arch_default,
167 ldemul_default_target,
168 before_allocation_default,
169 gld_${EMULATION_NAME}_get_script,
173 NULL, /* create output section statements */
174 NULL, /* open dynamic archive */
175 NULL, /* place orphan */
176 NULL, /* set_symbols */
177 NULL, /* parse_args */
178 gld${EMULATION_NAME}_add_options,
179 gld${EMULATION_NAME}_handle_option,
180 NULL, /* unrecognized_file */
181 gld_${EMULATION_NAME}_list_options,
182 NULL, /* recognized file */
183 NULL, /* find_potential_libraries */
184 NULL, /* new_vers_pattern */
185 NULL /* extra_map_file_text */