Regenerate spu overlay and icache manager files
[deliverable/binutils-gdb.git] / ld / emultempl / linux.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
b34976b6 3if [ -z "$MACHINE" ]; then
86af25fe
L
4 OUTPUT_ARCH=${ARCH}
5else
6 OUTPUT_ARCH=${ARCH}:${MACHINE}
7fi
92b93329 8fragment <<EOF
252b5132
RH
9/* This file is is generated by a shell script. DO NOT EDIT! */
10
11/* Linux a.out emulation code for ${EMULATION_NAME}
4b95cf5c 12 Copyright (C) 1991-2014 Free Software Foundation, Inc.
252b5132
RH
13 Written by Steve Chamberlain <sac@cygnus.com>
14 Linux support by Eric Youngdale <ericy@cais.cais.com>
15
f96b4a7b 16 This file is part of the GNU Binutils.
252b5132 17
f96b4a7b
NC
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.
252b5132 22
f96b4a7b
NC
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.
252b5132 27
f96b4a7b
NC
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. */
252b5132
RH
32
33#define TARGET_IS_${EMULATION_NAME}
34
252b5132 35#include "sysdep.h"
3db64b00 36#include "bfd.h"
252b5132
RH
37#include "bfdlink.h"
38
39#include "ld.h"
40#include "ldmain.h"
252b5132
RH
41#include "ldmisc.h"
42#include "ldexp.h"
43#include "ldlang.h"
b71e2778
AM
44#include "ldfile.h"
45#include "ldemul.h"
252b5132 46
252b5132 47static void
0c7a8e5a 48gld${EMULATION_NAME}_before_parse (void)
252b5132 49{
5e2f1575 50 ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
66be1055 51 input_flags.dynamic = TRUE;
b34976b6 52 config.has_shared = TRUE;
252b5132
RH
53}
54
55/* Try to open a dynamic archive. This is where we know that Linux
56 dynamic libraries have an extension of .sa. */
57
b34976b6 58static bfd_boolean
0c7a8e5a
AM
59gld${EMULATION_NAME}_open_dynamic_archive
60 (const char *arch, search_dirs_type *search, lang_input_statement_type *entry)
252b5132
RH
61{
62 char *string;
63
d4ae5fb0 64 if (! entry->flags.maybe_archive || entry->flags.full_name_provided)
b34976b6 65 return FALSE;
252b5132
RH
66
67 string = (char *) xmalloc (strlen (search->name)
68 + strlen (entry->filename)
69 + strlen (arch)
70 + sizeof "/lib.sa");
71
72 sprintf (string, "%s/lib%s%s.sa", search->name, entry->filename, arch);
73
74 if (! ldfile_try_open_bfd (string, entry))
75 {
76 free (string);
b34976b6 77 return FALSE;
252b5132
RH
78 }
79
80 entry->filename = string;
81
b34976b6 82 return TRUE;
252b5132
RH
83}
84
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
90 Linux tools. */
91
92static void
0c7a8e5a 93gld${EMULATION_NAME}_find_address_statement (lang_statement_union_type *s)
252b5132
RH
94{
95 if (s->header.type == lang_address_statement_enum
96 && strcmp (s->address_statement.section_name, ".text") == 0)
97 {
98 ASSERT (s->address_statement.address->type.node_class == etree_value);
99 s->address_statement.address->value.value += 0x20;
100 }
101}
102
103/* This is called before opening the input BFD's. */
104
105static void
0c7a8e5a 106gld${EMULATION_NAME}_create_output_section_statements (void)
252b5132
RH
107{
108 lang_for_each_statement (gld${EMULATION_NAME}_find_address_statement);
109}
110
111/* This is called after the sections have been attached to output
112 sections, but before any sizes or addresses have been set. */
113
114static void
0c7a8e5a 115gld${EMULATION_NAME}_before_allocation (void)
252b5132 116{
1049f94e 117 if (link_info.relocatable)
252b5132
RH
118 return;
119
120 /* Let the backend work out the sizes of any sections required by
121 dynamic linking. */
f13a99db
AM
122 if (! bfd_${EMULATION_NAME}_size_dynamic_sections (link_info.output_bfd,
123 &link_info))
252b5132 124 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
8423293d 125
1e035701 126 before_allocation_default ();
252b5132
RH
127}
128
129static char *
0c7a8e5a 130gld${EMULATION_NAME}_get_script (int *isfile)
252b5132
RH
131EOF
132
7225345d 133if test x"$COMPILE_IN" = xyes
252b5132
RH
134then
135# Scripts compiled in.
136
137# sed commands to quote an ld script as a C string.
597e2591 138sc="-f stringify.sed"
252b5132 139
92b93329 140fragment <<EOF
b34976b6 141{
252b5132
RH
142 *isfile = 0;
143
1049f94e 144 if (link_info.relocatable && config.build_constructors)
597e2591 145 return
252b5132 146EOF
b34976b6 147sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1049f94e 148echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
b34976b6
AM
149sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
150echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
151sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
152echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
153sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
154echo ' ; else return' >> e${EMULATION_NAME}.c
155sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
156echo '; }' >> e${EMULATION_NAME}.c
252b5132
RH
157
158else
159# Scripts read from the filesystem.
160
92b93329 161fragment <<EOF
b34976b6 162{
252b5132
RH
163 *isfile = 1;
164
1049f94e 165 if (link_info.relocatable && config.build_constructors)
252b5132 166 return "ldscripts/${EMULATION_NAME}.xu";
1049f94e 167 else if (link_info.relocatable)
252b5132
RH
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";
173 else
174 return "ldscripts/${EMULATION_NAME}.x";
175}
176EOF
177
178fi
179
92b93329 180fragment <<EOF
252b5132 181
b34976b6 182struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
252b5132
RH
183{
184 gld${EMULATION_NAME}_before_parse,
185 syslib_default,
186 hll_default,
187 after_parse_default,
188 after_open_default,
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,
194 "${EMULATION_NAME}",
195 "${OUTPUT_FORMAT}",
1e035701 196 finish_default,
252b5132 197 gld${EMULATION_NAME}_create_output_section_statements,
49bdcdba 198 gld${EMULATION_NAME}_open_dynamic_archive,
e1c47aa4
AM
199 NULL, /* place orphan */
200 NULL, /* set symbols */
201 NULL, /* parse args */
3bcf5557
AM
202 NULL, /* add_options */
203 NULL, /* handle_option */
e1c47aa4
AM
204 NULL, /* unrecognized file */
205 NULL, /* list options */
40d109bf 206 NULL, /* recognized file */
fac1652d 207 NULL, /* find_potential_libraries */
7a2f2d82
DD
208 NULL, /* new_vers_pattern */
209 NULL /* extra_map_file_text */
252b5132
RH
210};
211EOF
This page took 0.598766 seconds and 4 git commands to generate.