00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "bfd.h"
00028 #include "sysdep.h"
00029 #include "getopt.h"
00030
00031 #include "ld.h"
00032 #include "ldmisc.h"
00033 #include "ldexp.h"
00034 #include "ldlang.h"
00035 #include "ldfile.h"
00036 #include "ldemul.h"
00037 #include "ldmain.h"
00038 #include "ldemul-list.h"
00039
00040 ld_emulation_xfer_type *ld_emulation;
00041
00042 void
00043 ldemul_hll (char *name)
00044 {
00045 ld_emulation->hll (name);
00046 }
00047
00048 void
00049 ldemul_syslib (char *name)
00050 {
00051 ld_emulation->syslib (name);
00052 }
00053
00054 void
00055 ldemul_after_parse (void)
00056 {
00057 ld_emulation->after_parse ();
00058 }
00059
00060 void
00061 ldemul_before_parse (void)
00062 {
00063 ld_emulation->before_parse ();
00064 }
00065
00066 void
00067 ldemul_after_open (void)
00068 {
00069 ld_emulation->after_open ();
00070 }
00071
00072 void
00073 ldemul_after_allocation (void)
00074 {
00075 ld_emulation->after_allocation ();
00076 }
00077
00078 void
00079 ldemul_before_allocation (void)
00080 {
00081 if (ld_emulation->before_allocation)
00082 ld_emulation->before_allocation ();
00083 }
00084
00085 void
00086 ldemul_set_output_arch (void)
00087 {
00088 ld_emulation->set_output_arch ();
00089 }
00090
00091 void
00092 ldemul_finish (void)
00093 {
00094 if (ld_emulation->finish)
00095 ld_emulation->finish ();
00096 }
00097
00098 void
00099 ldemul_set_symbols (void)
00100 {
00101 if (ld_emulation->set_symbols)
00102 ld_emulation->set_symbols ();
00103 }
00104
00105 void
00106 ldemul_create_output_section_statements (void)
00107 {
00108 if (ld_emulation->create_output_section_statements)
00109 ld_emulation->create_output_section_statements ();
00110 }
00111
00112 char *
00113 ldemul_get_script (int *isfile)
00114 {
00115 return ld_emulation->get_script (isfile);
00116 }
00117
00118 bfd_boolean
00119 ldemul_open_dynamic_archive (const char *arch, search_dirs_type *search,
00120 lang_input_statement_type *entry)
00121 {
00122 if (ld_emulation->open_dynamic_archive)
00123 return (*ld_emulation->open_dynamic_archive) (arch, search, entry);
00124 return FALSE;
00125 }
00126
00127 bfd_boolean
00128 ldemul_place_orphan (lang_input_statement_type *file, asection *s)
00129 {
00130 if (ld_emulation->place_orphan)
00131 return (*ld_emulation->place_orphan) (file, s);
00132 return FALSE;
00133 }
00134
00135 void
00136 ldemul_add_options (int ns, char **shortopts, int nl,
00137 struct option **longopts, int nrl,
00138 struct option **really_longopts)
00139 {
00140 if (ld_emulation->add_options)
00141 (*ld_emulation->add_options) (ns, shortopts, nl, longopts,
00142 nrl, really_longopts);
00143 }
00144
00145 bfd_boolean
00146 ldemul_handle_option (int optc)
00147 {
00148 if (ld_emulation->handle_option)
00149 return (*ld_emulation->handle_option) (optc);
00150 return FALSE;
00151 }
00152
00153 bfd_boolean
00154 ldemul_parse_args (int argc, char **argv)
00155 {
00156
00157 if (ld_emulation->parse_args)
00158 return (*ld_emulation->parse_args) (argc, argv);
00159 return FALSE;
00160 }
00161
00162
00163
00164 bfd_boolean
00165 ldemul_unrecognized_file (lang_input_statement_type *entry)
00166 {
00167 if (ld_emulation->unrecognized_file)
00168 return (*ld_emulation->unrecognized_file) (entry);
00169 return FALSE;
00170 }
00171
00172
00173
00174 bfd_boolean
00175 ldemul_recognized_file (lang_input_statement_type *entry)
00176 {
00177 if (ld_emulation->recognized_file)
00178 return (*ld_emulation->recognized_file) (entry);
00179 return FALSE;
00180 }
00181
00182 char *
00183 ldemul_choose_target (int argc, char **argv)
00184 {
00185 return ld_emulation->choose_target (argc, argv);
00186 }
00187
00188
00189
00190
00191 char *
00192 ldemul_default_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
00193 {
00194 char *from_outside = getenv (TARGET_ENVIRON);
00195 if (from_outside != (char *) NULL)
00196 return from_outside;
00197 return ld_emulation->target_name;
00198 }
00199
00200 void
00201 after_parse_default (void)
00202 {
00203 }
00204
00205 void
00206 after_open_default (void)
00207 {
00208 }
00209
00210 void
00211 after_allocation_default (void)
00212 {
00213 }
00214
00215 void
00216 before_allocation_default (void)
00217 {
00218 }
00219
00220 void
00221 set_output_arch_default (void)
00222 {
00223
00224 bfd_set_arch_mach (output_bfd,
00225 ldfile_output_architecture, ldfile_output_machine);
00226 }
00227
00228 void
00229 syslib_default (char *ignore ATTRIBUTE_UNUSED)
00230 {
00231 info_msg (_("%S SYSLIB ignored\n"));
00232 }
00233
00234 void
00235 hll_default (char *ignore ATTRIBUTE_UNUSED)
00236 {
00237 info_msg (_("%S HLL ignored\n"));
00238 }
00239
00240 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
00241
00242 void
00243 ldemul_choose_mode (char *target)
00244 {
00245 ld_emulation_xfer_type **eptr = ld_emulations;
00246
00247 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
00248 target += 3;
00249 for (; *eptr; eptr++)
00250 {
00251 if (strcmp (target, (*eptr)->emulation_name) == 0)
00252 {
00253 ld_emulation = *eptr;
00254 return;
00255 }
00256 }
00257 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
00258 einfo (_("Supported emulations: "));
00259 ldemul_list_emulations (stderr);
00260 einfo ("%F\n");
00261 }
00262
00263 void
00264 ldemul_list_emulations (FILE *f)
00265 {
00266 ld_emulation_xfer_type **eptr = ld_emulations;
00267 bfd_boolean first = TRUE;
00268
00269 for (; *eptr; eptr++)
00270 {
00271 if (first)
00272 first = FALSE;
00273 else
00274 fprintf (f, " ");
00275 fprintf (f, "%s", (*eptr)->emulation_name);
00276 }
00277 }
00278
00279 void
00280 ldemul_list_emulation_options (FILE *f)
00281 {
00282 ld_emulation_xfer_type **eptr;
00283 int options_found = 0;
00284
00285 for (eptr = ld_emulations; *eptr; eptr++)
00286 {
00287 ld_emulation_xfer_type *emul = *eptr;
00288
00289 if (emul->list_options)
00290 {
00291 fprintf (f, "%s: \n", emul->emulation_name);
00292
00293 emul->list_options (f);
00294
00295 options_found = 1;
00296 }
00297 }
00298
00299 if (! options_found)
00300 fprintf (f, _(" no emulation specific options.\n"));
00301 }
00302
00303 int
00304 ldemul_find_potential_libraries (char *name, lang_input_statement_type *entry)
00305 {
00306 if (ld_emulation->find_potential_libraries)
00307 return ld_emulation->find_potential_libraries (name, entry);
00308
00309 return 0;
00310 }
00311
00312 struct bfd_elf_version_expr *
00313 ldemul_new_vers_pattern (struct bfd_elf_version_expr *entry)
00314 {
00315 if (ld_emulation->new_vers_pattern)
00316 entry = (*ld_emulation->new_vers_pattern) (entry);
00317 return entry;
00318 }