From: Ken Raeburn Date: Tue, 23 May 1995 00:09:34 +0000 (+0000) Subject: more emulation fixes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4761bb029a85d6a85cd8b041b1a28a94ddf0f516;p=binutils-gdb.git more emulation fixes --- diff --git a/gas/ChangeLog b/gas/ChangeLog index c7049af2ec4..c54bb7c47b1 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +Mon May 22 20:03:23 1995 Ken Raeburn + + * config/e-mipself.c (mipself): New emulation mode, doesn't change + endianness from configured default. + * config/e-mipsecoff.c (mipsecoff): Ditto. + * configure.in (mips ecoff/elf targets): Include them. + * as.c (mipself, mipsecoff): Declare. + + * as.c (emulation_name): New variable. + (select_emulation_mode): Set emulation_name. Don't change argv. + (parse_args): Handle --emulation; complain if the supplied name + isn't what select_emulation_name came up with. + start-sanitize-arc Mon May 22 16:56:58 1995 Doug Evans diff --git a/gas/as.c b/gas/as.c index 182f78c7d40..bc8ce44fe83 100644 --- a/gas/as.c +++ b/gas/as.c @@ -104,6 +104,90 @@ Options:\n\ md_show_usage (stream); } +#ifdef USE_EMULATIONS +#define EMULATION_ENVIRON "AS_EMULATION" + +extern struct emulation mipsbelf, mipslelf, mipself; +extern struct emulation mipsbecoff, mipslecoff, mipsecoff; + +static const char *emulation_name; +static struct emulation *const emulations[] = { EMULATIONS }; +static const int n_emulations = sizeof (emulations) / sizeof (emulations[0]); + +static void +select_emulation_mode (argc, argv) + int argc; + char **argv; +{ + int i; + char *p, *em = 0; + + for (i = 1; i < argc; i++) + if (!strncmp ("--em", argv[i], 4)) + break; + + if (i == argc) + goto do_default; + + p = strchr (argv[i], '='); + if (p) + p++; + else + p = argv[i+1]; + + if (!p || !*p) + as_fatal ("missing emulation mode name"); + em = p; + + do_default: + if (em == 0) + em = getenv (EMULATION_ENVIRON); + if (em == 0) + em = DEFAULT_EMULATION; + + if (em) + { + for (i = 0; i < n_emulations; i++) + if (!strcmp (emulations[i]->name, em)) + break; + if (i == n_emulations) + as_fatal ("unrecognized emulation name `%s'", em); + this_emulation = emulations[i]; + } + else + this_emulation = emulations[0]; + + this_emulation->init (); +} + +const char * +default_emul_bfd_name () +{ + abort (); +} + +void +common_emul_init () +{ + this_format = this_emulation->format; + + if (this_emulation->leading_underscore == 2) + this_emulation->leading_underscore = this_format->dfl_leading_underscore; + + if (this_emulation->default_endian != 2) + target_big_endian = this_emulation->default_endian; + + if (this_emulation->fake_label_name == 0) + { + if (this_emulation->leading_underscore) + this_emulation->fake_label_name = "L0\001"; + else + /* What other parameters should we test? */ + this_emulation->fake_label_name = ".L0\001"; + } +} +#endif + /* * Since it is easy to do here we interpret the special arg "-" * to mean "use stdin" and we set that argv[] pointing to "". @@ -153,6 +237,8 @@ parse_args (pargc, pargv) {"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}, #define OPTION_VERBOSE (OPTION_STD_BASE + 5) {"verbose", no_argument, NULL, OPTION_VERBOSE}, +#define OPTION_EMULATION (OPTION_STD_BASE + 6) + {"emulation", required_argument, NULL, OPTION_EMULATION}, }; /* Construct the option lists from the standard list and the @@ -237,6 +323,12 @@ parse_args (pargc, pargv) print_version_id (); exit (EXIT_SUCCESS); + case OPTION_EMULATION: + /* Already handled; ignore it this time, except error checking. */ + if (strcmp (optarg, this_emulation->name)) + as_fatal ("multiple emulation names specified"); + break; + case OPTION_DUMPCONFIG: fprintf (stderr, "alias = %s\n", TARGET_ALIAS); fprintf (stderr, "canonical = %s\n", TARGET_CANONICAL); @@ -370,10 +462,15 @@ main (argc, argv) out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; + hex_init (); #ifdef BFD_ASSEMBLER bfd_init (); #endif +#ifdef USE_EMULATIONS + select_emulation_mode (argc, argv); +#endif + PROGRESS (1); symbol_begin (); frag_init ();