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