Updated Malay translation for the bfd sub-directory
[binutils-gdb.git] / ld / emultempl / ticoff.em
blobd4ef91f7af2c551e1281b09be2881c867b221612
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 fragment <<EOF
5 /* This file is part of GLD, the Gnu Linker.
6    Copyright (C) 1999-2025 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.  */
25 /* For TI COFF */
26 /* Need to determine load and run pages for output sections */
28 #define TARGET_IS_${EMULATION_NAME}
30 #include "sysdep.h"
31 #include "libiberty.h"
32 #include "bfd.h"
33 #include "bfdlink.h"
34 #include "ctf-api.h"
35 #include "getopt.h"
37 #include "ld.h"
38 #include "ldmain.h"
39 #include "ldmisc.h"
40 #include "ldexp.h"
41 #include "ldlang.h"
42 #include "ldfile.h"
43 #include "ldlex.h"
44 #include "ldemul.h"
46 static int coff_version;
48 /* TI COFF extra command line options */
50 static void
51 gld${EMULATION_NAME}_add_options
52   (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
53    struct option **longopts, int nrl ATTRIBUTE_UNUSED,
54    struct option **really_longopts ATTRIBUTE_UNUSED)
56   static const struct option xtra_long[] = {
57     /* TI COFF options */
58     {"format", required_argument, NULL, OPTION_COFF_FORMAT },
59     {NULL, no_argument, NULL, 0}
60   };
62   *longopts = (struct option *)
63     xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
64   memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
67 static void
68 gld${EMULATION_NAME}_list_options (FILE * file)
70   fprintf (file, _("  --format 0|1|2              Specify which COFF version to use\n"));
73 static bool
74 gld${EMULATION_NAME}_handle_option (int optc)
76   switch (optc)
77     {
78     default:
79       return false;
81     case OPTION_COFF_FORMAT:
82       if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
83           && optarg[1] == '\0')
84         {
85           static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
86           coff_version = *optarg - '0';
87           buf[4] = *optarg;
88           lang_add_output_format (buf, NULL, NULL, 0);
89         }
90       else
91         {
92           einfo (_("%F%P: invalid COFF format version %s\n"), optarg);
93         }
94       break;
95     }
96   return false;
99 static void
100 gld${EMULATION_NAME}_before_parse(void)
102 #ifndef TARGET_                 /* I.e., if not generic.  */
103   ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
104 #endif /* not TARGET_ */
107 static char *
108 gld${EMULATION_NAME}_get_script (int *isfile)
110 if test x"$COMPILE_IN" = xyes
111 then
112 # Scripts compiled in.
114 # sed commands to quote an ld script as a C string.
115 sc='s/["\\]/\\&/g
116 s/$/\\n\\/
117 1s/^/"/
118 $s/$/n"/
120 fragment <<EOF
122   *isfile = 0;
123   if (bfd_link_relocatable (&link_info) && config.build_constructors)
124     return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
125   else if (bfd_link_relocatable (&link_info))
126     return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
127   else if (!config.text_read_only)
128     return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
129   else if (!config.magic_demand_paged)
130     return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
131   else
132     return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
136 else
137 # Scripts read from the filesystem.
139 fragment <<EOF
141   *isfile = 1;
143   if (bfd_link_relocatable (&link_info) && config.build_constructors)
144     return "ldscripts/${EMULATION_NAME}.xu";
145   else if (bfd_link_relocatable (&link_info))
146     return "ldscripts/${EMULATION_NAME}.xr";
147   else if (!config.text_read_only)
148     return "ldscripts/${EMULATION_NAME}.xbn";
149   else if (!config.magic_demand_paged)
150     return "ldscripts/${EMULATION_NAME}.xn";
151   else
152     return "ldscripts/${EMULATION_NAME}.x";
158 LDEMUL_ADD_OPTIONS=gld${EMULATION_NAME}_add_options
159 LDEMUL_HANDLE_OPTION=gld${EMULATION_NAME}_handle_option
160 LDEMUL_LIST_OPTIONS=gld${EMULATION_NAME}_list_options
162 source_em ${srcdir}/emultempl/emulation.em