update generated files
[binutils.git] / ld / emultempl / armelf_oabi.em
blob1f2deb385d61ed46e9f8ea085aa09f5a63ca9ac8
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! */
6 /* emulate the original gld for the given ${EMULATION_NAME}
7    Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000
8    Free Software Foundation, Inc.
9    Written by Steve Chamberlain steve@cygnus.com
11 This file is part of GLD, the Gnu Linker.
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.
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.
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.  */
27 #define TARGET_IS_${EMULATION_NAME}
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
36 #include "bfd.h"
37 #include "sysdep.h"
38 #include "bfdlink.h"
39 #include "getopt.h"
41 #include "ld.h"
42 #include "ldmain.h"
43 #include "ldmisc.h"
45 #include "ldexp.h"
46 #include "ldlang.h"
47 #include "ldfile.h"
48 #include "ldemul.h"
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));
54 static void
55 gld${EMULATION_NAME}_before_parse ()
57 #ifndef TARGET_                 /* I.e., if not generic.  */
58   ldfile_set_output_arch ("`echo ${ARCH}`");
59 #endif /* not TARGET_ */
62 /* This is called after the sections have been attached to output
63    sections, but before any sizes or addresses have been set.  */
65 static void
66 gld${EMULATION_NAME}_before_allocation ()
68   /* we should be able to set the size of the interworking stub section */
70   /* Here we rummage through the found bfds to collect glue information */
71   /* FIXME: should this be based on a command line option? krk@cygnus.com */
72   {
73     LANG_FOR_EACH_INPUT_STATEMENT (is)
74       {
75         if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, &link_info, 0))
76           {
77             /* xgettext:c-format */
78             einfo (_("Errors encountered processing file %s"), is->filename);
79           }
80       }
81   }
83   /* We have seen it all. Allocate it, and carry on */
84   bfd_elf32_arm_allocate_interworking_sections (& link_info);
87 static void
88 gld${EMULATION_NAME}_after_open ()
91   LANG_FOR_EACH_INPUT_STATEMENT (is)
92     {
93       /* The interworking bfd must be the last one to be processed */
94       if (!is->next)
95          bfd_elf32_arm_get_bfd_for_interworking (is->the_bfd, & link_info);
96     }
99 static char *
100 gld${EMULATION_NAME}_get_script (isfile)
101      int *isfile;
104 if test -n "$COMPILE_IN"
105 then
106 # Scripts compiled in.
108 # sed commands to quote an ld script as a C string.
109 sc="-f stringify.sed"
111 cat >>e${EMULATION_NAME}.c <<EOF
112 {                            
113   *isfile = 0;
115   if (link_info.relocateable == true && config.build_constructors == true)
116     return
118 sed $sc ldscripts/${EMULATION_NAME}.xu                     >> e${EMULATION_NAME}.c
119 echo '  ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
120 sed $sc ldscripts/${EMULATION_NAME}.xr                     >> e${EMULATION_NAME}.c
121 echo '  ; else if (!config.text_read_only) return'         >> e${EMULATION_NAME}.c
122 sed $sc ldscripts/${EMULATION_NAME}.xbn                    >> e${EMULATION_NAME}.c
123 echo '  ; else if (!config.magic_demand_paged) return'     >> e${EMULATION_NAME}.c
124 sed $sc ldscripts/${EMULATION_NAME}.xn                     >> e${EMULATION_NAME}.c
125 echo '  ; else return'                                     >> e${EMULATION_NAME}.c
126 sed $sc ldscripts/${EMULATION_NAME}.x                      >> e${EMULATION_NAME}.c
127 echo '; }'                                                 >> e${EMULATION_NAME}.c
129 else
130 # Scripts read from the filesystem.
132 cat >>e${EMULATION_NAME}.c <<EOF
133 {                            
134   *isfile = 1;
136   if (link_info.relocateable == true && config.build_constructors == true)
137     return "ldscripts/${EMULATION_NAME}.xu";
138   else if (link_info.relocateable == true)
139     return "ldscripts/${EMULATION_NAME}.xr";
140   else if (!config.text_read_only)
141     return "ldscripts/${EMULATION_NAME}.xbn";
142   else if (!config.magic_demand_paged)
143     return "ldscripts/${EMULATION_NAME}.xn";
144   else
145     return "ldscripts/${EMULATION_NAME}.x";
151 cat >>e${EMULATION_NAME}.c <<EOF
153 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
155   gld${EMULATION_NAME}_before_parse,
156   syslib_default,
157   hll_default,
158   after_parse_default,
159   gld${EMULATION_NAME}_after_open,
160   after_allocation_default,
161   set_output_arch_default,
162   ldemul_default_target,
163   gld${EMULATION_NAME}_before_allocation,
164   gld${EMULATION_NAME}_get_script,
165   "${EMULATION_NAME}",
166   "${OUTPUT_FORMAT}",
167   NULL, /* finish */
168   NULL, /* create output section statements */
169   NULL, /* open dynamic archive */
170   NULL, /* place orphan */
171   NULL, /* set symbols */
172   NULL, /* parse args */
173   NULL, /* unrecognized file */
174   NULL, /* list options */
175   NULL, /* recognized file */
176   NULL  /* find_potential_libraries */