]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/ticoff.em
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / emultempl / ticoff.em
CommitLineData
74459f0e
TW
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 ;-)
92b93329 4fragment <<EOF
74459f0e 5/* This file is part of GLD, the Gnu Linker.
250d07de 6 Copyright (C) 1999-2021 Free Software Foundation, Inc.
74459f0e 7
f96b4a7b
NC
8 This file is part of the GNU Binutils.
9
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.
14
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.
19
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. */
74459f0e
TW
24
25/* For TI COFF */
5e2f1575
AM
26/* Need to determine load and run pages for output sections */
27
74459f0e
TW
28#define TARGET_IS_${EMULATION_NAME}
29
74459f0e 30#include "sysdep.h"
3db64b00 31#include "bfd.h"
74459f0e 32#include "bfdlink.h"
1ff6de03 33#include "ctf-api.h"
fcf65871 34#include "getopt.h"
74459f0e
TW
35
36#include "ld.h"
37#include "ldmain.h"
74459f0e 38#include "ldmisc.h"
b71e2778
AM
39#include "ldexp.h"
40#include "ldlang.h"
41#include "ldfile.h"
42#include "ldemul.h"
43
74459f0e
TW
44static int coff_version;
45
74459f0e
TW
46/* TI COFF extra command line options */
47#define OPTION_COFF_FORMAT (300 + 1)
48
3bcf5557 49static void
0c7a8e5a
AM
50gld${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)
74459f0e 54{
3bcf5557
AM
55 static const struct option xtra_long[] = {
56 /* TI COFF options */
57 {"format", required_argument, NULL, OPTION_COFF_FORMAT },
58 {NULL, no_argument, NULL, 0}
59 };
60
61 *longopts = (struct option *)
62 xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
63 memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
64}
74459f0e
TW
65
66static void
0c7a8e5a 67gld_${EMULATION_NAME}_list_options (FILE * file)
74459f0e 68{
442996ee 69 fprintf (file, _(" --format 0|1|2 Specify which COFF version to use\n"));
5e2f1575 70}
74459f0e 71
3bcf5557 72static bfd_boolean
0c7a8e5a 73gld${EMULATION_NAME}_handle_option (int optc)
74459f0e 74{
74459f0e
TW
75 switch (optc)
76 {
77 default:
3bcf5557 78 return FALSE;
74459f0e
TW
79
80 case OPTION_COFF_FORMAT:
81 if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
6c19b93b
AM
82 && optarg[1] == '\0')
83 {
84 static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
85 coff_version = *optarg - '0';
86 buf[4] = *optarg;
87 lang_add_output_format (buf, NULL, NULL, 0);
88 }
74459f0e 89 else
6c19b93b 90 {
df5f2391 91 einfo (_("%F%P: invalid COFF format version %s\n"), optarg);
6c19b93b 92 }
74459f0e
TW
93 break;
94 }
3bcf5557 95 return FALSE;
74459f0e
TW
96}
97
98static void
0c7a8e5a 99gld_${EMULATION_NAME}_before_parse(void)
74459f0e
TW
100{
101#ifndef TARGET_ /* I.e., if not generic. */
5e2f1575 102 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
74459f0e
TW
103#endif /* not TARGET_ */
104}
105
106static char *
0c7a8e5a 107gld_${EMULATION_NAME}_get_script (int *isfile)
74459f0e 108EOF
7225345d 109if test x"$COMPILE_IN" = xyes
74459f0e
TW
110then
111# Scripts compiled in.
112
113# sed commands to quote an ld script as a C string.
114sc='s/["\\]/\\&/g
115s/$/\\n\\/
1161s/^/"/
117$s/$/n"/
118'
92b93329 119fragment <<EOF
5e2f1575 120{
74459f0e 121 *isfile = 0;
0e1862bb 122 if (bfd_link_relocatable (&link_info) && config.build_constructors)
74459f0e 123 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
0e1862bb 124 else if (bfd_link_relocatable (&link_info))
74459f0e
TW
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`;
130 else
131 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
132}
133EOF
134
135else
136# Scripts read from the filesystem.
137
92b93329 138fragment <<EOF
5e2f1575 139{
74459f0e
TW
140 *isfile = 1;
141
0e1862bb 142 if (bfd_link_relocatable (&link_info) && config.build_constructors)
74459f0e 143 return "ldscripts/${EMULATION_NAME}.xu";
0e1862bb 144 else if (bfd_link_relocatable (&link_info))
74459f0e
TW
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";
150 else
151 return "ldscripts/${EMULATION_NAME}.x";
152}
153EOF
154
155fi
156
92b93329 157fragment <<EOF
5e2f1575 158struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
74459f0e
TW
159{
160 gld_${EMULATION_NAME}_before_parse,
161 syslib_default,
162 hll_default,
163 after_parse_default,
164 after_open_default,
5c3261b0 165 after_check_relocs_default,
9b538ba7 166 before_place_orphans_default,
74459f0e
TW
167 after_allocation_default,
168 set_output_arch_default,
169 ldemul_default_target,
170 before_allocation_default,
171 gld_${EMULATION_NAME}_get_script,
172 "${EMULATION_NAME}",
173 "${OUTPUT_FORMAT}",
1e035701 174 finish_default,
74459f0e
TW
175 NULL, /* create output section statements */
176 NULL, /* open dynamic archive */
177 NULL, /* place orphan */
178 NULL, /* set_symbols */
3bcf5557
AM
179 NULL, /* parse_args */
180 gld${EMULATION_NAME}_add_options,
181 gld${EMULATION_NAME}_handle_option,
74459f0e
TW
182 NULL, /* unrecognized_file */
183 gld_${EMULATION_NAME}_list_options,
184 NULL, /* recognized file */
fac1652d 185 NULL, /* find_potential_libraries */
7a2f2d82 186 NULL, /* new_vers_pattern */
1ff6de03
NA
187 NULL, /* extra_map_file_text */
188 ${LDEMUL_EMIT_CTF_EARLY-NULL},
3d16b64e
NA
189 ${LDEMUL_ACQUIRE_STRINGS_FOR_CTF-NULL},
190 ${LDEMUL_NEW_DYNSYM_FOR_CTF-NULL},
3edf7b9f 191 ${LDEMUL_PRINT_SYMBOL-NULL}
74459f0e
TW
192};
193EOF