1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 if [ -z "$MACHINE" ]; then
6 OUTPUT_ARCH=${ARCH}:${MACHINE}
9 /* This file is is generated by a shell script. DO NOT EDIT! */
11 /* Linux a.out emulation code for ${EMULATION_NAME}
12 Copyright (C) 1991-2014 Free Software Foundation, Inc.
13 Written by Steve Chamberlain <sac@cygnus.com>
14 Linux support by Eric Youngdale <ericy@cais.cais.com>
16 This file is part of the GNU Binutils.
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 3 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
31 MA 02110-1301, USA. */
33 #define TARGET_IS_${EMULATION_NAME}
48 gld${EMULATION_NAME}_before_parse (void)
50 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
51 input_flags.dynamic = TRUE;
52 config.has_shared = TRUE;
55 /* Try to open a dynamic archive. This is where we know that Linux
56 dynamic libraries have an extension of .sa. */
59 gld${EMULATION_NAME}_open_dynamic_archive
60 (const char *arch, search_dirs_type *search, lang_input_statement_type *entry)
64 if (! entry->flags.maybe_archive || entry->flags.full_name_provided)
67 string = (char *) xmalloc (strlen (search->name)
68 + strlen (entry->filename)
72 sprintf (string, "%s/lib%s%s.sa", search->name, entry->filename, arch);
74 if (! ldfile_try_open_bfd (string, entry))
80 entry->filename = string;
85 /* This is called by the create_output_section_statements routine via
86 lang_for_each_statement. It locates any address assignment to
87 .text, and modifies it to include the size of the headers. This
88 causes -Ttext to mean the starting address of the header, rather
89 than the starting address of .text, which is compatible with other
93 gld${EMULATION_NAME}_find_address_statement (lang_statement_union_type *s)
95 if (s->header.type == lang_address_statement_enum
96 && strcmp (s->address_statement.section_name, ".text") == 0)
98 ASSERT (s->address_statement.address->type.node_class == etree_value);
99 s->address_statement.address->value.value += 0x20;
103 /* This is called before opening the input BFD's. */
106 gld${EMULATION_NAME}_create_output_section_statements (void)
108 lang_for_each_statement (gld${EMULATION_NAME}_find_address_statement);
111 /* This is called after the sections have been attached to output
112 sections, but before any sizes or addresses have been set. */
115 gld${EMULATION_NAME}_before_allocation (void)
117 if (link_info.relocatable)
120 /* Let the backend work out the sizes of any sections required by
122 if (! bfd_${EMULATION_NAME}_size_dynamic_sections (link_info.output_bfd,
124 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
126 before_allocation_default ();
130 gld${EMULATION_NAME}_get_script (int *isfile)
133 if test x"$COMPILE_IN" = xyes
135 # Scripts compiled in.
137 # sed commands to quote an ld script as a C string.
138 sc="-f stringify.sed"
144 if (link_info.relocatable && config.build_constructors)
147 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
148 echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
149 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
150 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
151 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
152 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
153 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
154 echo ' ; else return' >> e${EMULATION_NAME}.c
155 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
156 echo '; }' >> e${EMULATION_NAME}.c
159 # Scripts read from the filesystem.
165 if (link_info.relocatable && config.build_constructors)
166 return "ldscripts/${EMULATION_NAME}.xu";
167 else if (link_info.relocatable)
168 return "ldscripts/${EMULATION_NAME}.xr";
169 else if (!config.text_read_only)
170 return "ldscripts/${EMULATION_NAME}.xbn";
171 else if (!config.magic_demand_paged)
172 return "ldscripts/${EMULATION_NAME}.xn";
174 return "ldscripts/${EMULATION_NAME}.x";
182 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
184 gld${EMULATION_NAME}_before_parse,
189 after_allocation_default,
190 set_output_arch_default,
191 ldemul_default_target,
192 gld${EMULATION_NAME}_before_allocation,
193 gld${EMULATION_NAME}_get_script,
197 gld${EMULATION_NAME}_create_output_section_statements,
198 gld${EMULATION_NAME}_open_dynamic_archive,
199 NULL, /* place orphan */
200 NULL, /* set symbols */
201 NULL, /* parse args */
202 NULL, /* add_options */
203 NULL, /* handle_option */
204 NULL, /* unrecognized file */
205 NULL, /* list options */
206 NULL, /* recognized file */
207 NULL, /* find_potential_libraries */
208 NULL, /* new_vers_pattern */
209 NULL /* extra_map_file_text */