]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/armelf_oabi.em
import gdb-2000-01-24 snapshot
[thirdparty/binutils-gdb.git] / ld / emultempl / armelf_oabi.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
4/* This file is is generated by a shell script. DO NOT EDIT! */
5
6/* emulate the original gld for the given ${EMULATION_NAME}
7 Copyright (C) 1991, 93, 96, 97, 98, 1999 Free Software Foundation, Inc.
8 Written by Steve Chamberlain steve@cygnus.com
9
10This file is part of GLD, the Gnu Linker.
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2 of the License, or
15(at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25
26#define TARGET_IS_${EMULATION_NAME}
27
28#define bfd_elf32_arm_allocate_interworking_sections \
29 bfd_elf32_arm_oabi_allocate_interworking_sections
30#define bfd_elf32_arm_get_bfd_for_interworking \
31 bfd_elf32_arm_oabi_get_bfd_for_interworking
32#define bfd_elf32_arm_process_before_allocation \
33 bfd_elf32_arm_oabi_process_before_allocation
34
35#include "bfd.h"
36#include "sysdep.h"
37#include "bfdlink.h"
38#include "getopt.h"
39
40#include "ld.h"
41#include "ldmain.h"
42#include "ldemul.h"
43#include "ldfile.h"
44#include "ldmisc.h"
45
46#include "ldexp.h"
47#include "ldlang.h"
48
49static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
50static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
51static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
52
53static void
54gld${EMULATION_NAME}_before_parse ()
55{
56#ifndef TARGET_ /* I.e., if not generic. */
57 ldfile_set_output_arch ("`echo ${ARCH}`");
58#endif /* not TARGET_ */
59}
60
61/* This is called after the sections have been attached to output
62 sections, but before any sizes or addresses have been set. */
63
64static void
65gld${EMULATION_NAME}_before_allocation ()
66{
67 /* we should be able to set the size of the interworking stub section */
68
69 /* Here we rummage through the found bfds to collect glue information */
70 /* FIXME: should this be based on a command line option? krk@cygnus.com */
71 {
72 LANG_FOR_EACH_INPUT_STATEMENT (is)
73 {
7ca69e9e 74 if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, &link_info, 0))
252b5132
RH
75 {
76 /* xgettext:c-format */
77 einfo (_("Errors encountered processing file %s"), is->filename);
78 }
79 }
80 }
81
82 /* We have seen it all. Allocate it, and carry on */
83 bfd_elf32_arm_allocate_interworking_sections (& link_info);
84}
85
86static void
87gld${EMULATION_NAME}_after_open ()
88{
89
90 LANG_FOR_EACH_INPUT_STATEMENT (is)
91 {
92 /* The interworking bfd must be the last one to be processed */
93 if (!is->next)
94 bfd_elf32_arm_get_bfd_for_interworking (is->the_bfd, & link_info);
95 }
96}
97
98static char *
99gld${EMULATION_NAME}_get_script (isfile)
100 int *isfile;
101EOF
102
103if test -n "$COMPILE_IN"
104then
105# Scripts compiled in.
106
107# sed commands to quote an ld script as a C string.
597e2591 108sc="-f stringify.sed"
252b5132
RH
109
110cat >>e${EMULATION_NAME}.c <<EOF
111{
112 *isfile = 0;
113
114 if (link_info.relocateable == true && config.build_constructors == true)
115 return
116EOF
117sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
118echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
119sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
120echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
121sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
122echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
123sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
124echo ' ; else return' >> e${EMULATION_NAME}.c
125sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
126echo '; }' >> e${EMULATION_NAME}.c
127
128else
129# Scripts read from the filesystem.
130
131cat >>e${EMULATION_NAME}.c <<EOF
132{
133 *isfile = 1;
134
135 if (link_info.relocateable == true && config.build_constructors == true)
136 return "ldscripts/${EMULATION_NAME}.xu";
137 else if (link_info.relocateable == true)
138 return "ldscripts/${EMULATION_NAME}.xr";
139 else if (!config.text_read_only)
140 return "ldscripts/${EMULATION_NAME}.xbn";
141 else if (!config.magic_demand_paged)
142 return "ldscripts/${EMULATION_NAME}.xn";
143 else
144 return "ldscripts/${EMULATION_NAME}.x";
145}
146EOF
147
148fi
149
150cat >>e${EMULATION_NAME}.c <<EOF
151
152struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
153{
154 gld${EMULATION_NAME}_before_parse,
155 syslib_default,
156 hll_default,
157 after_parse_default,
158 gld${EMULATION_NAME}_after_open,
159 after_allocation_default,
160 set_output_arch_default,
161 ldemul_default_target,
162 gld${EMULATION_NAME}_before_allocation,
163 gld${EMULATION_NAME}_get_script,
164 "${EMULATION_NAME}",
165 "${OUTPUT_FORMAT}",
e1c47aa4
AM
166 NULL, /* finish */
167 NULL, /* create output section statements */
168 NULL, /* open dynamic archive */
169 NULL, /* place orphan */
170 NULL, /* set symbols */
171 NULL, /* parse args */
172 NULL, /* unrecognized file */
173 NULL, /* list options */
174 NULL /* recognized file */
252b5132
RH
175};
176EOF