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 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 /* Need to determine load and run pages for output sections */
25 #define TARGET_IS_${EMULATION_NAME}
42 static int coff_version;
44 static void gld_${EMULATION_NAME}_before_parse PARAMS ((void));
45 static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
46 static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
47 static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE *));
49 /* TI COFF extra command line options */
50 #define OPTION_COFF_FORMAT (300 + 1)
52 static struct option longopts[] =
55 {"format", required_argument, NULL, OPTION_COFF_FORMAT },
56 {NULL, no_argument, NULL, 0}
60 gld_${EMULATION_NAME}_list_options (file)
63 fprintf (file, _(" --format 0|1|2 Specify which COFF version to use"));
67 gld_${EMULATION_NAME}_parse_args(argc, argv)
73 int prevoptind = optind;
74 int prevopterr = opterr;
76 static int lastoptind = -1;
78 if (lastoptind != optind)
84 optc = getopt_long_only (argc, argv, "-", longopts, &longind);
95 case OPTION_COFF_FORMAT:
96 if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
99 extern void lang_add_output_format
100 PARAMS ((const char *, const char *, const char *, int));
101 static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
102 coff_version = *optarg - '0';
104 lang_add_output_format (buf, NULL, NULL, 0);
108 einfo (_("%P%F: invalid COFF format version %s\n"), optarg);
117 gld_${EMULATION_NAME}_before_parse()
119 #ifndef TARGET_ /* I.e., if not generic. */
120 ldfile_set_output_arch ("`echo ${ARCH}`");
121 #endif /* not TARGET_ */
125 gld_${EMULATION_NAME}_get_script (isfile)
128 if test -n "$COMPILE_IN"
130 # Scripts compiled in.
132 # sed commands to quote an ld script as a C string.
138 cat >>e${EMULATION_NAME}.c <<EOF
141 if (link_info.relocateable == true && config.build_constructors == true)
142 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
143 else if (link_info.relocateable == true)
144 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
145 else if (!config.text_read_only)
146 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
147 else if (!config.magic_demand_paged)
148 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
150 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
155 # Scripts read from the filesystem.
157 cat >>e${EMULATION_NAME}.c <<EOF
161 if (link_info.relocateable == true && config.build_constructors == true)
162 return "ldscripts/${EMULATION_NAME}.xu";
163 else if (link_info.relocateable == true)
164 return "ldscripts/${EMULATION_NAME}.xr";
165 else if (!config.text_read_only)
166 return "ldscripts/${EMULATION_NAME}.xbn";
167 else if (!config.magic_demand_paged)
168 return "ldscripts/${EMULATION_NAME}.xn";
170 return "ldscripts/${EMULATION_NAME}.x";
176 cat >>e${EMULATION_NAME}.c <<EOF
177 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
179 gld_${EMULATION_NAME}_before_parse,
184 after_allocation_default,
185 set_output_arch_default,
186 ldemul_default_target,
187 before_allocation_default,
188 gld_${EMULATION_NAME}_get_script,
192 NULL, /* create output section statements */
193 NULL, /* open dynamic archive */
194 NULL, /* place orphan */
195 NULL, /* set_symbols */
196 gld_${EMULATION_NAME}_parse_args,
197 NULL, /* unrecognized_file */
198 gld_${EMULATION_NAME}_list_options,
199 NULL, /* recognized file */
200 NULL /* find_potential_libraries */