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