Commit | Line | Data |
---|---|---|
252b5132 RH |
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} | |
5e2f1575 AM |
7 | Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
8 | 2004 Free Software Foundation, Inc. | |
252b5132 RH |
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" | |
252b5132 RH |
43 | #include "ldmisc.h" |
44 | ||
45 | #include "ldexp.h" | |
46 | #include "ldlang.h" | |
b71e2778 AM |
47 | #include "ldfile.h" |
48 | #include "ldemul.h" | |
252b5132 | 49 | |
252b5132 | 50 | static void |
0c7a8e5a | 51 | gld${EMULATION_NAME}_before_parse (void) |
252b5132 RH |
52 | { |
53 | #ifndef TARGET_ /* I.e., if not generic. */ | |
5e2f1575 | 54 | ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); |
252b5132 RH |
55 | #endif /* not TARGET_ */ |
56 | } | |
57 | ||
58 | /* This is called after the sections have been attached to output | |
59 | sections, but before any sizes or addresses have been set. */ | |
60 | ||
61 | static void | |
0c7a8e5a | 62 | gld${EMULATION_NAME}_before_allocation (void) |
252b5132 RH |
63 | { |
64 | /* we should be able to set the size of the interworking stub section */ | |
65 | ||
66 | /* Here we rummage through the found bfds to collect glue information */ | |
67 | /* FIXME: should this be based on a command line option? krk@cygnus.com */ | |
68 | { | |
69 | LANG_FOR_EACH_INPUT_STATEMENT (is) | |
70 | { | |
7ca69e9e | 71 | if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, &link_info, 0)) |
252b5132 RH |
72 | { |
73 | /* xgettext:c-format */ | |
74 | einfo (_("Errors encountered processing file %s"), is->filename); | |
75 | } | |
76 | } | |
77 | } | |
78 | ||
79 | /* We have seen it all. Allocate it, and carry on */ | |
80 | bfd_elf32_arm_allocate_interworking_sections (& link_info); | |
81 | } | |
82 | ||
83 | static void | |
0c7a8e5a | 84 | gld${EMULATION_NAME}_after_open (void) |
252b5132 RH |
85 | { |
86 | ||
87 | LANG_FOR_EACH_INPUT_STATEMENT (is) | |
88 | { | |
89 | /* The interworking bfd must be the last one to be processed */ | |
90 | if (!is->next) | |
91 | bfd_elf32_arm_get_bfd_for_interworking (is->the_bfd, & link_info); | |
92 | } | |
93 | } | |
94 | ||
95 | static char * | |
0c7a8e5a | 96 | gld${EMULATION_NAME}_get_script (int *isfile) |
252b5132 RH |
97 | EOF |
98 | ||
99 | if test -n "$COMPILE_IN" | |
100 | then | |
101 | # Scripts compiled in. | |
102 | ||
103 | # sed commands to quote an ld script as a C string. | |
597e2591 | 104 | sc="-f stringify.sed" |
252b5132 RH |
105 | |
106 | cat >>e${EMULATION_NAME}.c <<EOF | |
0c7a8e5a | 107 | { |
252b5132 RH |
108 | *isfile = 0; |
109 | ||
1049f94e | 110 | if (link_info.relocatable && config.build_constructors) |
252b5132 RH |
111 | return |
112 | EOF | |
b34976b6 | 113 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
1049f94e | 114 | echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c |
b34976b6 AM |
115 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c |
116 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
117 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
118 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
119 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
120 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
121 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
122 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
123 | |
124 | else | |
125 | # Scripts read from the filesystem. | |
126 | ||
127 | cat >>e${EMULATION_NAME}.c <<EOF | |
0c7a8e5a | 128 | { |
252b5132 RH |
129 | *isfile = 1; |
130 | ||
1049f94e | 131 | if (link_info.relocatable && config.build_constructors) |
252b5132 | 132 | return "ldscripts/${EMULATION_NAME}.xu"; |
1049f94e | 133 | else if (link_info.relocatable) |
252b5132 RH |
134 | return "ldscripts/${EMULATION_NAME}.xr"; |
135 | else if (!config.text_read_only) | |
136 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
137 | else if (!config.magic_demand_paged) | |
138 | return "ldscripts/${EMULATION_NAME}.xn"; | |
139 | else | |
140 | return "ldscripts/${EMULATION_NAME}.x"; | |
141 | } | |
142 | EOF | |
143 | ||
144 | fi | |
145 | ||
146 | cat >>e${EMULATION_NAME}.c <<EOF | |
147 | ||
0c7a8e5a | 148 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = |
252b5132 RH |
149 | { |
150 | gld${EMULATION_NAME}_before_parse, | |
151 | syslib_default, | |
152 | hll_default, | |
153 | after_parse_default, | |
154 | gld${EMULATION_NAME}_after_open, | |
155 | after_allocation_default, | |
156 | set_output_arch_default, | |
157 | ldemul_default_target, | |
158 | gld${EMULATION_NAME}_before_allocation, | |
159 | gld${EMULATION_NAME}_get_script, | |
160 | "${EMULATION_NAME}", | |
161 | "${OUTPUT_FORMAT}", | |
e1c47aa4 AM |
162 | NULL, /* finish */ |
163 | NULL, /* create output section statements */ | |
164 | NULL, /* open dynamic archive */ | |
165 | NULL, /* place orphan */ | |
166 | NULL, /* set symbols */ | |
167 | NULL, /* parse args */ | |
3bcf5557 AM |
168 | NULL, /* add_options */ |
169 | NULL, /* handle_option */ | |
e1c47aa4 AM |
170 | NULL, /* unrecognized file */ |
171 | NULL, /* list options */ | |
40d109bf | 172 | NULL, /* recognized file */ |
fac1652d AM |
173 | NULL, /* find_potential_libraries */ |
174 | NULL /* new_vers_pattern */ | |
252b5132 RH |
175 | }; |
176 | EOF |