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-2022 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}
44 static int coff_version;
46 /* TI COFF extra command line options */
47 #define OPTION_COFF_FORMAT (300 + 1)
50 gld${EMULATION_NAME}_add_options
51 (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
52 struct option **longopts, int nrl ATTRIBUTE_UNUSED,
53 struct option **really_longopts ATTRIBUTE_UNUSED)
55 static const struct option xtra_long[] = {
57 {"format", required_argument, NULL, OPTION_COFF_FORMAT },
58 {NULL, no_argument, NULL, 0}
61 *longopts = (struct option *)
62 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
63 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
67 gld${EMULATION_NAME}_list_options (FILE * file)
69 fprintf (file, _(" --format 0|1|2 Specify which COFF version to use\n"));
73 gld${EMULATION_NAME}_handle_option (int optc)
80 case OPTION_COFF_FORMAT:
81 if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
84 static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
85 coff_version = *optarg - '0';
87 lang_add_output_format (buf, NULL, NULL, 0);
91 einfo (_("%F%P: invalid COFF format version %s\n"), optarg);
99 gld${EMULATION_NAME}_before_parse(void)
101 #ifndef TARGET_ /* I.e., if not generic. */
102 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
103 #endif /* not TARGET_ */
107 gld${EMULATION_NAME}_get_script (int *isfile)
109 if test x"$COMPILE_IN" = xyes
111 # Scripts compiled in.
113 # sed commands to quote an ld script as a C string.
122 if (bfd_link_relocatable (&link_info) && config.build_constructors)
123 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
124 else if (bfd_link_relocatable (&link_info))
125 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
126 else if (!config.text_read_only)
127 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
128 else if (!config.magic_demand_paged)
129 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
131 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
136 # Scripts read from the filesystem.
142 if (bfd_link_relocatable (&link_info) && config.build_constructors)
143 return "ldscripts/${EMULATION_NAME}.xu";
144 else if (bfd_link_relocatable (&link_info))
145 return "ldscripts/${EMULATION_NAME}.xr";
146 else if (!config.text_read_only)
147 return "ldscripts/${EMULATION_NAME}.xbn";
148 else if (!config.magic_demand_paged)
149 return "ldscripts/${EMULATION_NAME}.xn";
151 return "ldscripts/${EMULATION_NAME}.x";
157 LDEMUL_ADD_OPTIONS=gld${EMULATION_NAME}_add_options
158 LDEMUL_HANDLE_OPTION=gld${EMULATION_NAME}_handle_option
159 LDEMUL_LIST_OPTIONS=gld${EMULATION_NAME}_list_options
161 source_em ${srcdir}/emultempl/emulation.em