First cut at handling multiple emulation modes for some MIPS targets.
authorKen Raeburn <raeburn@cygnus>
Wed, 10 May 1995 23:08:40 +0000 (23:08 +0000)
committerKen Raeburn <raeburn@cygnus>
Wed, 10 May 1995 23:08:40 +0000 (23:08 +0000)
Mostly works, not entirely.
Details in ChangeLog.

12 files changed:
gas/ChangeLog
gas/acconfig.h
gas/conf.in
gas/config/e-mipsecoff.c [new file with mode: 0644]
gas/config/e-mipself.c [new file with mode: 0644]
gas/config/obj-elf.c
gas/config/obj-multi.c [new file with mode: 0644]
gas/config/te-multi.h [new file with mode: 0644]
gas/configure
gas/configure.in
gas/emul-target.h [new file with mode: 0644]
gas/emul.h [new file with mode: 0644]

index 356c1577a0711b4842f14c7bbae92bc0eed50430..0a150bfaeb63f7bdbd6721fc3b6b75524d4a8c90 100644 (file)
@@ -1,3 +1,106 @@
+Wed May 10 18:09:12 1995  Ken Raeburn  <raeburn@cujo.cygnus.com>
+
+       * Makefile.in (OBJS): Include @extra_objects@.
+       (obj-elf.o, obj-ecoff.o, e-mipself.o, e-mipsecoff.o): New rules
+       for building these independently.
+       * emul-target.h, config/e-mipself.c, config/e-mipsecoff.c: New
+       files.
+
+       * acconfig.h (DEFAULT_EMULATION, EMULATIONS, USE_EMULATIONS,
+       OBJ_MAYBE_*, I386COFF, M68KCOFF, M88KCOFF): New macros.
+       * aclocal.m4 (GAS_UNIQ): New macro.
+
+       * as.c (emulations, n_emulations) [USE_EMULATIONS]: New variable.
+       (select_emulation_mode, default_emul_bfd_name, common_emul_init)
+       [USE_EMULATIONS]: New functions.
+       (main) [USE_EMULATIONS]: Call select_emulation_mode before other
+       initialization.
+       * emul.h: New file.
+       * as.h [USE_EMULATIONS]: Include it.
+
+       * configure.in: Handle enable-targets option.  Iterate over target
+       list, building up a list of object file formats and emulation
+       configurations.  (Only supports emulations for MIPS CPU so far.)
+       If multiple formats are needed, set obj_format to multi and add
+       format config files to extra_files.  If emulation modes are
+       needed, add the relevant files to extra_files.
+
+       * configure.in: Define I386COFF, M68KCOFF, M88KCOFF for those
+       configurations.
+
+       * ecoff.c (ecoff_generate_asm_lineno): Filename argument now
+       points to const.
+       * ecoff.h (ecoff_generate_asm_lineno): Updated declaration.
+
+       * obj.h (obj_read_begin_hook): Don't declare function if it's
+       already a macro.
+
+       * read.c (s_space, cons, stringer): If md_flush_pending_output is
+       defined, call it on entry.
+       * config/obj-elf.c (obj_elf_section): If md_flush_pending_output
+       is defined, call it on entry.  If md_elf_section_change_hook is
+       defined, call it before returning normally.
+
+       * read.h (target_big_endian): Declare.
+
+       * obj.h (struct format_ops): Added new function pointer fields
+       ecoff_set_ext, read_begin_hook, symbol_new_hook.
+       (ecoff_format_ops, elf_format_ops): Declare.
+       * config/obj-elf.c (elf_s_get_size, elf_s_set_size,
+       elf_s_get_align, elf_s_set_align, elf_copy_symbol_attributes,
+       elf_sec_sym_ok_for_reloc): New functions.
+       (elf_format_ops): New variable.
+       (elf_frob_symbol): Now takes additional int* argument.
+       * config/obj-elf.h (elf_frob_symbol): Update declaration.
+       (elf_pop_insert): Declare.
+       (obj_pop_insert): Define to call elf_pop_insert.
+       * config/obj-ecoff.c (ecoff_sec_sym_ok_for_reloc,
+       obj_ecoff_frob_symbol): New functions.
+       (ecoff_format_ops): New variable.
+
+       * config/te-generic.h: If OBJ_HEADER is defined, use it as the
+       filename to include in place of obj-format.h.
+       * config/te-multi.h: New file, copied from te-generic.h.
+       * config/obj-elf.c (OBJ_HEADER): Define it to "obj-elf.h".
+       * config/obj-ecoff.c (OBJ_HEADER): Define it to "obj-ecoff.h".
+
+       * config/obj-elf.c (ECOFF_DEBUGGING): Default to 0.
+       (obj_read_begin_hook, obj_symbol_new_hook, elf_frob_symbol,
+       elf_frob_file): Test it at run time.
+       (obj_ecoff_set_ext, elf_get_extr, elf_set_index): Define
+       unconditionally.
+       (elf_pseudo_table): Renamed from obj_pseudo_table, now static.
+       (ecoff_debug_pseudo_table): Split off into separate table.  Define
+       it unconditionally.
+       (elf_pop_insert): New function.
+       * config/obj-elf.h (elf_pop_insert): Declare.
+       (obj_pop_insert): New macro.
+       (obj_ecoff_set_ext) [!OBJ_MAYBE_ELF]: Define to elf_ecoff_set_ext.
+       * config/obj-ecoff.h (obj_ecoff_set_ext): Define to ecoff_set_ext.
+
+       * config/tc-mips.h: Protect against multiple inclusions.
+       (mips_pop_insert): Declare.
+       (md_pop_insert): Call it.
+
+       * config/tc-mips.c: If OBJ_MAYBE_ELF is defined, include
+       obj-elf.h, but preserve OUTPUT_FLAVOR and protect some other
+       macros from redefinition.
+       (ECOFF_DEBUGGING): Default to 0.  All references changed to
+       run-time tests or made unconditional.
+       (s_stringer, s_mips_space, s_elf_section): Deleted.
+       (md_pseudo_table): Don't refer to them.  Split table into three
+       sections, for MIPS, non-ECOFF_DEBUGGING, and ELF.
+       (mips_pop_insert): New function.
+       (mips_flush_pending_output): New function.
+       (mips_enable_auto_align): New function.
+       * config/tc-mips.h (mips_pop_insert): Declare.
+       (md_pop_insert): New macro.
+       (mips_flush_pending_output): Declare.
+       (md_flush_pending_output): New macro.
+       (mips_enable_auto_align): Declare.
+       (md_elf_section_change_hook): New macro, calls
+       mips_enable_auto_align.
+
 Tue May  9 17:07:41 1995  Michael Meissner  <meissner@tiktok.cygnus.com>
 
        * configure.in: Add little endian PowerPC support.
index 5d1541240ec12fd397e73bf0b61cde049aa35c51..57fdd83e5bbbeb0cdd379e1a2ad631d12f1d15f9 100644 (file)
 
 /* Needed only for sparc configuration */
 #undef sparcv9
+
+/* Needed only for some configurations that can produce multiple output
+   formats.  */
+#undef DEFAULT_EMULATION
+#undef EMULATIONS
+#undef USE_EMULATIONS
+#undef OBJ_MAYBE_AOUT
+#undef OBJ_MAYBE_BOUT
+#undef OBJ_MAYBE_COFF
+#undef OBJ_MAYBE_ECOFF
+#undef OBJ_MAYBE_ELF
+#undef OBJ_MAYBE_GENERIC
+#undef OBJ_MAYBE_HP300
+#undef OBJ_MAYBE_IEEE
+#undef OBJ_MAYBE_SOM
+#undef OBJ_MAYBE_VMS
+
+/* Used for some of the COFF configurations, when the COFF code needs
+   to select something based on the CPU type before it knows it... */
+#undef I386COFF
+#undef M68KCOFF
+#undef M88KCOFF
index c2d8d4a4b4d194a05e12944eb9b5a09690b999ff..fca9d46c665139ef407e16431e18ea06891e87ad 100644 (file)
 /* Needed only for sparc configuration */
 #undef sparcv9
 
+/* Needed only for some configurations that can produce multiple output
+   formats.  */
+#undef DEFAULT_EMULATION
+#undef EMULATIONS
+#undef USE_EMULATIONS
+#undef OBJ_MAYBE_AOUT
+#undef OBJ_MAYBE_BOUT
+#undef OBJ_MAYBE_COFF
+#undef OBJ_MAYBE_ECOFF
+#undef OBJ_MAYBE_ELF
+#undef OBJ_MAYBE_GENERIC
+#undef OBJ_MAYBE_HP300
+#undef OBJ_MAYBE_IEEE
+#undef OBJ_MAYBE_SOM
+#undef OBJ_MAYBE_VMS
+
+/* Used for some of the COFF configurations, when the COFF code needs
+   to select something based on the CPU type before it knows it... */
+#undef I386COFF
+#undef M68KCOFF
+#undef M88KCOFF
+
 /* Define if you have the remove function.  */
 #undef HAVE_REMOVE
 
diff --git a/gas/config/e-mipsecoff.c b/gas/config/e-mipsecoff.c
new file mode 100644 (file)
index 0000000..e766ee1
--- /dev/null
@@ -0,0 +1,25 @@
+#include "as.h"
+#include "emul.h"
+
+static const char *
+mipsecoff_bfd_name ()
+{
+  abort ();
+}
+
+#define emul_bfd_name  mipsecoff_bfd_name
+#define emul_format    &ecoff_format_ops
+
+#define emul_name      "mipsbecoff"
+#define emul_struct_name mipsbecoff
+#define emul_default_endian 1
+#include "emul-target.h"
+
+#undef  emul_name
+#undef  emul_struct_name
+#undef  emul_default_endian
+
+#define emul_name      "mipslecoff"
+#define emul_struct_name mipslecoff
+#define emul_default_endian 0
+#include "emul-target.h"
diff --git a/gas/config/e-mipself.c b/gas/config/e-mipself.c
new file mode 100644 (file)
index 0000000..a2ba055
--- /dev/null
@@ -0,0 +1,25 @@
+#include "as.h"
+#include "emul.h"
+
+static const char *
+mipself_bfd_name ()
+{
+  abort ();
+}
+
+#define emul_bfd_name  mipself_bfd_name
+#define emul_format    &elf_format_ops
+
+#define emul_name      "mipsbelf"
+#define emul_struct_name mipsbelf
+#define emul_default_endian 1
+#include "emul-target.h"
+
+#undef  emul_name
+#undef  emul_struct_name
+#undef  emul_default_endian
+
+#define emul_name      "mipslelf"
+#define emul_struct_name mipslelf
+#define emul_default_endian 0
+#include "emul-target.h"
index 33429e5fde474be8acb07585877ed04093f3da92..a349e55aad924ad6a1332e22ada8725ced0b8c3f 100644 (file)
    License along with GAS; see the file COPYING.  If not, write
    to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#define OBJ_HEADER "obj-elf.h"
 #include "as.h"
 #include "subsegs.h"
 #include "obstack.h"
 
-#ifdef ECOFF_DEBUGGING
+#ifndef ECOFF_DEBUGGING
+#define ECOFF_DEBUGGING 0
+#endif
+
+#if ECOFF_DEBUGGING
 #include "ecoff.h"
 #endif
 
@@ -29,7 +34,7 @@
 #include "elf/mips.h"
 #endif
 
-#ifdef ECOFF_DEBUGGING
+#if ECOFF_DEBUGGING
 static boolean elf_get_extr PARAMS ((asymbol *, EXTR *));
 static void elf_set_index PARAMS ((asymbol *, bfd_size_type));
 #endif
@@ -45,7 +50,7 @@ static void obj_elf_common PARAMS ((int));
 static void obj_elf_data PARAMS ((int));
 static void obj_elf_text PARAMS ((int));
 
-const pseudo_typeS obj_pseudo_table[] =
+static const pseudo_typeS elf_pseudo_table[] =
 {
   {"comm", obj_elf_common, 0},
   {"ident", obj_elf_ident, 0},
@@ -69,7 +74,12 @@ const pseudo_typeS obj_pseudo_table[] =
   {"data", obj_elf_data, 0},
   {"text", obj_elf_text, 0},
 
-#ifdef ECOFF_DEBUGGING
+  /* End sentinel.  */
+  {NULL},
+};
+
+static const pseudo_typeS ecoff_debug_pseudo_table[] =
+{
   /* COFF style debugging information for ECOFF. .ln is not used; .loc
      is used instead.  */
   { "def",     ecoff_directive_def,    0 },
@@ -104,7 +114,6 @@ const pseudo_typeS obj_pseudo_table[] =
   { "noalias", s_ignore,               0 },
   { "verstamp",        s_ignore,               0 },
   { "vreg",    s_ignore,               0 },
-#endif /* ECOFF_DEBUGGING */
 
   {NULL}                       /* end sentinel */
 };
@@ -112,6 +121,58 @@ const pseudo_typeS obj_pseudo_table[] =
 #undef NO_RELOC
 #include "aout/aout64.h"
 
+void
+elf_pop_insert ()
+{
+  pop_insert (elf_pseudo_table);
+  if (ECOFF_DEBUGGING)
+    pop_insert (ecoff_debug_pseudo_table);
+}
+
+static bfd_vma
+elf_s_get_size (sym)
+     symbolS *sym;
+{
+  return S_GET_SIZE (sym);
+}
+
+static void
+elf_s_set_size (sym, sz)
+     symbolS *sym;
+     bfd_vma sz;
+{
+  S_SET_SIZE (sym, sz);
+}
+
+static bfd_vma
+elf_s_get_align (sym)
+     symbolS *sym;
+{
+  return S_GET_ALIGN (sym);
+}
+
+static void
+elf_s_set_align (sym, align)
+     symbolS *sym;
+     bfd_vma align;
+{
+  S_SET_ALIGN (sym, align);
+}
+
+static void
+elf_copy_symbol_attributes (dest, src)
+     symbolS *dest, *src;
+{
+  OBJ_COPY_SYMBOL_ATTRIBUTES (dest, src);
+}
+
+static int
+elf_sec_sym_ok_for_reloc (sec)
+     asection *sec;
+{
+  return obj_sec_sym_ok_for_reloc (sec);
+}
+
 void
 elf_file_symbol (s)
      char *s;
@@ -231,9 +292,10 @@ obj_elf_common (ignore)
        {
        allocate_common:
          S_SET_VALUE (symbolP, (valueT) size);
+         S_SET_ALIGN (symbolP, temp);
          S_SET_EXTERNAL (symbolP);
          /* should be common, but this is how gas does it for now */
-         S_SET_SEGMENT (symbolP, &bfd_und_section);
+         S_SET_SEGMENT (symbolP, bfd_und_section_ptr);
        }
     }
   else
@@ -410,6 +472,10 @@ obj_elf_section (xxx)
   int i;
   flagword flags;
 
+#ifdef md_flush_pending_output
+  md_flush_pending_output ();
+#endif
+
   /* Get name of section.  */
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
@@ -455,6 +521,11 @@ obj_elf_section (xxx)
       while (! is_end_of_line[(unsigned char) *input_line_pointer])
        ++input_line_pointer;
       ++input_line_pointer;
+
+#ifdef md_elf_section_change_hook
+      md_elf_section_change_hook ();
+#endif
+
       return;
     }
 
@@ -591,16 +662,23 @@ obj_elf_section (xxx)
           | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
           | ((attr & SHF_ALLOC) ? SEC_ALLOC | SEC_LOAD : 0)
           | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
-  if (type == SHT_PROGBITS)
-    flags |= SEC_ALLOC | SEC_LOAD;
-  else if (type == SHT_NOBITS)
+  if (special_sections[i].name == NULL)
     {
-      flags |= SEC_ALLOC;
-      flags &=~ SEC_LOAD;
+      if (type == SHT_PROGBITS)
+       flags |= SEC_ALLOC | SEC_LOAD;
+      else if (type == SHT_NOBITS)
+       {
+         flags |= SEC_ALLOC;
+         flags &=~ SEC_LOAD;
+       }
     }
 
   bfd_set_section_flags (stdoutput, sec, flags);
 
+#ifdef md_elf_section_change_hook
+  md_elf_section_change_hook ();
+#endif
+
   demand_empty_rest_of_line ();
 }
 
@@ -652,28 +730,18 @@ obj_elf_line (ignore)
 void 
 obj_read_begin_hook ()
 {
-#ifdef ECOFF_DEBUGGING
-  ecoff_read_begin_hook ();
-#endif
+  if (ECOFF_DEBUGGING)
+    ecoff_read_begin_hook ();
 }
 
 void 
 obj_symbol_new_hook (symbolP)
      symbolS *symbolP;
 {
-#if 0 /* BFD already takes care of this */
-  elf32_symbol_type *esym = (elf32_symbol_type *) symbolP;
+  symbolP->sy_obj = 0;
 
-  /* There is an Elf_Internal_Sym and an Elf_External_Sym.  For now,
-     just zero them out.  */
-
-  bzero ((char *) &esym->internal_elf_sym, sizeof (esym->internal_elf_sym));
-  bzero ((char *) &esym->native_elf_sym, sizeof (esym->native_elf_sym));
-  bzero ((char *) &esym->tc_data, sizeof (esym->tc_data));
-#endif
-#ifdef ECOFF_DEBUGGING
-  ecoff_symbol_new_hook (symbolP);
-#endif
+  if (ECOFF_DEBUGGING)
+    ecoff_symbol_new_hook (symbolP);
 }
 
 void 
@@ -779,64 +847,65 @@ obj_elf_size (ignore)
     S_SET_SIZE (sym, exp.X_add_number);
   else
     {
-#if 0
-      static int warned;
-      if (!warned)
-       {
-         as_tsktsk (".size expressions not yet supported, ignored");
-         warned++;
-       }
-#endif
+      sym->sy_obj = (expressionS *) xmalloc (sizeof (expressionS));
+      *sym->sy_obj = exp;
     }
   demand_empty_rest_of_line ();
 }
 
+/* Handle the ELF .type pseudo-op.  This sets the type of a symbol.
+   There are three syntaxes.  The first (used on Solaris) is
+       .type SYM,#function
+   The second (used on UnixWare) is
+       .type SYM,@function
+   The third (reportedly to be used on Irix 6.0) is
+       .type SYM STT_FUNC
+
+   FIXME: We do not fully support this pseudo-op.  In fact, the only
+   case we do support is setting the type to STT_FUNC, which we do by
+   setting the BSF_FUNCTION flag.  */
+
 static void
 obj_elf_type (ignore)
      int ignore;
 {
-  char *name = input_line_pointer;
-  char c = get_symbol_end ();
-  char *p;
-  int type = 0;
+  char *name;
+  char c;
+  int type;
+  const char *typename;
   symbolS *sym;
 
-  p = input_line_pointer;
-  *p = c;
+  name = input_line_pointer;
+  c = get_symbol_end ();
+  sym = symbol_find_or_make (name);
+  *input_line_pointer = c;
+
   SKIP_WHITESPACE ();
-  if (*input_line_pointer != ',')
-    {
-      as_bad ("expected comma after name in .type directive");
-    egress:
-      ignore_rest_of_line ();
-      return;
-    }
-  input_line_pointer++;
+  if (*input_line_pointer == ',')
+    ++input_line_pointer;
+
   SKIP_WHITESPACE ();
-  if (*input_line_pointer != '#' && *input_line_pointer != '@')
-    {
-      as_bad ("expected `#' or `@' after comma in .type directive");
-      goto egress;
-    }
-  input_line_pointer++;
-  if (!strncmp ("function", input_line_pointer, sizeof ("function") - 1))
-    {
-      type = BSF_FUNCTION;
-      input_line_pointer += sizeof ("function") - 1;
-    }
-  else if (!strncmp ("object", input_line_pointer, sizeof ("object") - 1))
-    {
-      input_line_pointer += sizeof ("object") - 1;
-    }
+  if (*input_line_pointer == '#' || *input_line_pointer == '@')
+    ++input_line_pointer;
+
+  typename = input_line_pointer;
+  c = get_symbol_end ();
+
+  type = 0;
+  if (strcmp (typename, "function") == 0
+      || strcmp (typename, "STT_FUNC") == 0)
+    type = BSF_FUNCTION;
+  else if (strcmp (typename, "object") == 0
+          || strcmp (typename, "STT_OBJECT") == 0)
+    ;
   else
-    {
-      as_bad ("unrecognized symbol type, ignored");
-      goto egress;
-    }
-  demand_empty_rest_of_line ();
-  *p = 0;
-  sym = symbol_find_or_make (name);
+    as_bad ("ignoring unrecognized symbol type \"%s\"", typename);
+
+  *input_line_pointer = c;
+
   sym->bsym->flags |= type;
+
+  demand_empty_rest_of_line ();
 }
 
 static void
@@ -879,7 +948,10 @@ obj_elf_init_stab_section (seg)
      UnixWare ar crashes.  */
   bfd_set_section_alignment (stdoutput, seg, 2);
 
+  /* Make space for this first symbol. */
   p = frag_more (12);
+  /* Zero it out. */
+  memset (p, 0, 12);
   as_where (&file, (unsigned int *) NULL);
   stabstr_name = (char *) alloca (strlen (segment_name (seg)) + 4);
   strcpy (stabstr_name, segment_name (seg));
@@ -927,7 +999,7 @@ adjust_stab_sections (abfd, sec, xxx)
   bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8);
 }
 
-#ifdef ECOFF_DEBUGGING
+/* #ifdef ECOFF_DEBUGGING */
 
 /* This function is called by the ECOFF code.  It is supposed to
    record the external symbol information so that the backend can
@@ -936,11 +1008,11 @@ adjust_stab_sections (abfd, sec, xxx)
    in the symbol.  */
 
 void
-obj_ecoff_set_ext (sym, ext)
+elf_ecoff_set_ext (sym, ext)
      symbolS *sym;
-     EXTR *ext;
+     struct ecoff_extr *ext;
 {
-  sym->bsym->udata = (PTR) ext;
+  sym->bsym->udata.p = (PTR) ext;
 }
 
 /* This function is called by bfd_ecoff_debug_externals.  It is
@@ -952,9 +1024,9 @@ elf_get_extr (sym, ext)
      asymbol *sym;
      EXTR *ext;
 {
-  if (sym->udata == NULL)
+  if (sym->udata.p == NULL)
     return false;
-  *ext = *(EXTR *) sym->udata;
+  *ext = *(EXTR *) sym->udata.p;
   return true;
 }
 
@@ -969,94 +1041,140 @@ elf_set_index (sym, indx)
 {
 }
 
-#endif /* ECOFF_DEBUGGING */
+/* #endif /* ECOFF_DEBUGGING */
+
+void
+elf_frob_symbol (symp, puntp)
+     symbolS *symp;
+     int *puntp;
+{
+  if (ECOFF_DEBUGGING)
+    ecoff_frob_symbol (symp);
+
+  if (symp->sy_obj)
+    {
+      switch (symp->sy_obj->X_op)
+       {
+       case O_subtract:
+         S_SET_SIZE (symp,
+                     (S_GET_VALUE (symp->sy_obj->X_add_symbol)
+                      + symp->sy_obj->X_add_number
+                      - S_GET_VALUE (symp->sy_obj->X_op_symbol)));
+         break;
+       case O_constant:
+         S_SET_SIZE (symp,
+                     (S_GET_VALUE (symp->sy_obj->X_add_symbol)
+                      + symp->sy_obj->X_add_number));
+         break;
+       default:
+         as_bad (".size expression too complicated to fix up");
+         break;
+       }
+    }
+  free (symp->sy_obj);
+  symp->sy_obj = 0;
+
+  /* Double check weak symbols.  */
+  if (symp->bsym->flags & BSF_WEAK)
+    {
+      if (S_IS_COMMON (symp))
+       as_bad ("Symbol `%s' can not be both weak and common",
+               S_GET_NAME (symp));
+    }
+}
 
 void 
 elf_frob_file ()
 {
   bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0);
 
-#ifdef elf_tc_symbol
-  {
-    int i;
-
-    for (i = 0; i < stdoutput->symcount; i++)
-      elf_tc_symbol (stdoutput, (PTR) (stdoutput->outsymbols[i]),
-                    i + 1);
-  }
-#endif
-
 #ifdef elf_tc_final_processing
   elf_tc_final_processing ();
 #endif
 
-  /* Finally, we must make any target-specific sections. */
-
-#ifdef elf_tc_make_sections
-  elf_tc_make_sections (stdoutput);
-#endif
-
-#ifdef ECOFF_DEBUGGING
-  /* Generate the ECOFF debugging information.  */
-  {
-    const struct ecoff_debug_swap *debug_swap;
-    struct ecoff_debug_info debug;
-    char *buf;
-    asection *sec;
+  if (ECOFF_DEBUGGING)
+    /* Generate the ECOFF debugging information.  */
+    {
+      const struct ecoff_debug_swap *debug_swap;
+      struct ecoff_debug_info debug;
+      char *buf;
+      asection *sec;
 
-    debug_swap
-      = get_elf_backend_data (stdoutput)->elf_backend_ecoff_debug_swap;
-    know (debug_swap != (const struct ecoff_debug_swap *) NULL);
-    ecoff_build_debug (&debug.symbolic_header, &buf, debug_swap);
+      debug_swap
+       = get_elf_backend_data (stdoutput)->elf_backend_ecoff_debug_swap;
+      know (debug_swap != (const struct ecoff_debug_swap *) NULL);
+      ecoff_build_debug (&debug.symbolic_header, &buf, debug_swap);
 
-    /* Set up the pointers in debug.  */
+      /* Set up the pointers in debug.  */
 #define SET(ptr, offset, type) \
     debug.ptr = (type) (buf + debug.symbolic_header.offset)
 
-    SET (line, cbLineOffset, unsigned char *);
-    SET (external_dnr, cbDnOffset, PTR);
-    SET (external_pdr, cbPdOffset, PTR);
-    SET (external_sym, cbSymOffset, PTR);
-    SET (external_opt, cbOptOffset, PTR);
-    SET (external_aux, cbAuxOffset, union aux_ext *);
-    SET (ss, cbSsOffset, char *);
-    SET (external_fdr, cbFdOffset, PTR);
-    SET (external_rfd, cbRfdOffset, PTR);
-    /* ssext and external_ext are set up just below.  */
+       SET (line, cbLineOffset, unsigned char *);
+      SET (external_dnr, cbDnOffset, PTR);
+      SET (external_pdr, cbPdOffset, PTR);
+      SET (external_sym, cbSymOffset, PTR);
+      SET (external_opt, cbOptOffset, PTR);
+      SET (external_aux, cbAuxOffset, union aux_ext *);
+      SET (ss, cbSsOffset, char *);
+      SET (external_fdr, cbFdOffset, PTR);
+      SET (external_rfd, cbRfdOffset, PTR);
+      /* ssext and external_ext are set up just below.  */
 
 #undef SET    
 
-    /* Set up the external symbols.  */
-    debug.ssext = debug.ssext_end = NULL;
-    debug.external_ext = debug.external_ext_end = NULL;
-    if (! bfd_ecoff_debug_externals (stdoutput, &debug, debug_swap, true,
-                                    elf_get_extr, elf_set_index))
-      as_fatal ("Failed to set up debugging information: %s",
-               bfd_errmsg (bfd_error));
-
-    sec = bfd_get_section_by_name (stdoutput, ".mdebug");
-    assert (sec != NULL);
-
-    know (stdoutput->output_has_begun == false);
-
-    /* We set the size of the section, call bfd_set_section_contents
-       to force the ELF backend to allocate a file position, and then
-       write out the data.  FIXME: Is this really the best way to do
-       this?  */
-    sec->_raw_size = bfd_ecoff_debug_size (stdoutput, &debug, debug_swap);
-
-    if (! bfd_set_section_contents (stdoutput, sec, (PTR) NULL,
-                                   (file_ptr) 0, (bfd_size_type) 0))
-      as_fatal ("Can't start writing .mdebug section: %s",
-               bfd_errmsg (bfd_error));
-
-    know (stdoutput->output_has_begun == true);
-    know (sec->filepos != 0);
-
-    if (! bfd_ecoff_write_debug (stdoutput, &debug, debug_swap,
-                                sec->filepos))
-      as_fatal ("Could not write .mdebug section: %s",
-               bfd_errmsg (bfd_error));
-  }
-#endif /* ECOFF_DEBUGGING */
+      /* Set up the external symbols.  */
+      debug.ssext = debug.ssext_end = NULL;
+      debug.external_ext = debug.external_ext_end = NULL;
+      if (! bfd_ecoff_debug_externals (stdoutput, &debug, debug_swap, true,
+                                      elf_get_extr, elf_set_index))
+       as_fatal ("Failed to set up debugging information: %s",
+                 bfd_errmsg (bfd_get_error ()));
+
+      sec = bfd_get_section_by_name (stdoutput, ".mdebug");
+      assert (sec != NULL);
+
+      know (stdoutput->output_has_begun == false);
+
+      /* We set the size of the section, call bfd_set_section_contents
+        to force the ELF backend to allocate a file position, and then
+        write out the data.  FIXME: Is this really the best way to do
+        this?  */
+      sec->_raw_size = bfd_ecoff_debug_size (stdoutput, &debug, debug_swap);
+
+      if (! bfd_set_section_contents (stdoutput, sec, (PTR) NULL,
+                                     (file_ptr) 0, (bfd_size_type) 0))
+       as_fatal ("Can't start writing .mdebug section: %s",
+                 bfd_errmsg (bfd_get_error ()));
+
+      know (stdoutput->output_has_begun == true);
+      know (sec->filepos != 0);
+
+      if (! bfd_ecoff_write_debug (stdoutput, &debug, debug_swap,
+                                  sec->filepos))
+       as_fatal ("Could not write .mdebug section: %s",
+                 bfd_errmsg (bfd_get_error ()));
+    }
 }
+
+const struct format_ops elf_format_ops =
+{
+  bfd_target_elf_flavour,
+  0,
+  1,
+  elf_frob_symbol,
+  elf_frob_file,
+  elf_s_get_size, elf_s_set_size,
+  elf_s_get_align, elf_s_set_align,
+  elf_copy_symbol_attributes,
+#ifdef ECOFF_DEBUGGING
+  ecoff_generate_asm_lineno,
+#else
+  0,
+#endif
+  0,                           /* process_stab */
+  elf_sec_sym_ok_for_reloc,
+  elf_pop_insert,
+  elf_ecoff_set_ext,
+  obj_read_begin_hook,
+  obj_symbol_new_hook,
+};
diff --git a/gas/config/obj-multi.c b/gas/config/obj-multi.c
new file mode 100644 (file)
index 0000000..d115093
--- /dev/null
@@ -0,0 +1,4 @@
+/* foo */
+
+#include "as.h"
+
diff --git a/gas/config/te-multi.h b/gas/config/te-multi.h
new file mode 100644 (file)
index 0000000..b8eda45
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * This file is te-generic.h and is intended to be a template for
+ * target environment specific header files.
+ *
+ * It is my intent that this file will evolve into a file suitable for config,
+ * compile, and copying as an aid for testing and porting.  xoxorich.
+ */
+
+/* Added these, because if we don't know what we're targetting we may
+   need an assembler version of libgcc, and that will use local
+   labels.  */
+#define LOCAL_LABELS_DOLLAR 1
+#define LOCAL_LABELS_FB 1
+
+/* these define interfaces */
+#ifdef OBJ_HEADER
+#include OBJ_HEADER
+#else
+#include "obj-format.h"
+#endif
+
+/* end of te-generic.h */
index e3fac7b15daaa30054a660e81ae5179284ce7a1a..c9d0fa29b8abeb168dc65d177e36112bd99f5221 100755 (executable)
@@ -13,6 +13,8 @@ ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
     bfd-assembler      use BFD back end for writing object files"
+ac_help="$ac_help
+    targets            alternative target configurations besides the primary"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -399,7 +401,6 @@ else
   ac_n= ac_c='\c' ac_t=
 fi
 
-bfd_gas=no
 user_bfd_gas=
 # Check whether --enable-bfd-assembler or --disable-bfd-assembler was given.
 enableval="$enable_bfd_assembler"
@@ -410,6 +411,16 @@ if test -n "$enableval"; then
   *)   { echo "configure: error: bad value ${enableval} given for bfd-assembler option" 1>&2; exit 1; } ;;
 esac
 fi
+# Check whether --enable-targets or --disable-targets was given.
+enableval="$enable_targets"
+if test -n "$enableval"; then
+  case "${enableval}" in
+  yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; }
+           ;;
+  no)      enable_targets= ;;
+  *)       enable_targets=$enableval ;;
+esac
+fi
 
 # Generate a header file -- gets more post-processing by Makefile later.
 
@@ -537,7 +548,7 @@ test "$program_suffix" != NONE &&
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 
-emulation=generic
+te_file=generic
 
 # assign cpu type
 
@@ -551,8 +562,7 @@ case ${target_cpu} in
   m8*)         cpu_type=m88k ;;
   mips*el)     cpu_type=mips endian=little;;
   mips*)       cpu_type=mips endian=big ;;
-  powerpcle*)  cpu_type=ppc endian=little;;
-  powerpc*)    cpu_type=ppc endian=big;;
+  powerpc*)    cpu_type=ppc ;;
   rs6000*)     cpu_type=ppc ;;
   sparc64)     cpu_type=sparc obj_format=elf
                cat >> confdefs.h <<\EOF
@@ -574,166 +584,283 @@ esac
 
 
 gas_target=${cpu_type}
-generic_target=${cpu_type}-${target_vendor}-${target_os}
-dev=no
+this_target=${generic_target}
+
+canon_targets=""
+if test -n "$enable_targets" ; then
+  for t in `echo $enable_targets | sed 's/,/ /g'`; do
+    result=`$ac_config_sub $t 2>/dev/null`
+    if test -n "$result" ; then
+      canon_targets="$canon_targets $result"
+#    else
+#      # Permit "all", etc.  We don't support it yet though.
+#      canon_targets="$canon_targets $t"
+    fi
+  done
+  _gas_uniq_list="$canon_targets"
+_gas_uniq_newlist=""
+for _gas_uniq_i in _gas_uniq_dummy $_gas_uniq_list ; do
+  case $_gas_uniq_i in
+  _gas_uniq_dummy) ;;
+  *) case " $_gas_uniq_newlist " in
+       *" $_gas_uniq_i "*) ;;
+       *) _gas_uniq_newlist="$_gas_uniq_newlist $_gas_uniq_i" ;;
+     esac ;;
+  esac
+done
+canon_targets=$_gas_uniq_newlist
+
+fi
+
+emulations=""
+
+for this_target in $target $canon_targets ; do
+
+    eval `echo $this_target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
+
+    # check for architecture variants
+    case ${cpu} in
+      hppa*)           cpu_type=hppa ;;
+      i[45]86)         cpu_type=i386 ;;
+      m680[012346]0)   cpu_type=m68k ;;
+      m68008)          cpu_type=m68k ;;
+      m683??)          cpu_type=m68k ;;
+      m8*)             cpu_type=m88k ;;
+      mips*el)         cpu_type=mips endian=little;;
+      mips*)           cpu_type=mips endian=big ;;
+      powerpcle*)      cpu_type=ppc endian=little ;;
+      powerpc*)                cpu_type=ppc endian=big ;;
+      rs6000*)         cpu_type=ppc ;;
+      sparc64)         cpu_type=sparc obj_format=elf want_sparcv9=true ;;
+      sparclite*)      cpu_type=sparc ;;
+      *)               cpu_type=${target_cpu} ;;
+    esac
+
+    if test ${this_target} = $target ; then
+      target_cpu_type=${cpu_type}
+    elif test ${target_cpu_type} != ${cpu_type} ; then
+      continue
+    fi
+
+    targ=${cpu_type}
+    generic_target=${cpu_type}-$vendor-$os
+    dev=no
+    bfd_gas=no
+    em=generic
 
-# assign object format
-case ${generic_target} in
-  a29k-amd-udi)                obj_format=coff gas_target=ebmon29k ;;
-  a29k-amd-ebmon)      obj_format=coff gas_target=ebmon29k ;;
-  a29k-*-vxworks*)      obj_format=coff ;;
+    # assign object format
+    case ${generic_target} in
+      a29k-amd-udi)         fmt=coff targ=ebmon29k ;;
+      a29k-amd-ebmon)       fmt=coff targ=ebmon29k ;;
+      a29k-*-vxworks*)      fmt=coff ;;
 
-  alpha-*-netware*)    obj_format=ecoff ;;
-  alpha-*-osf*)                obj_format=ecoff ;;
+      alpha-*-netware*)     fmt=ecoff ;;
+      alpha-*-osf*)         fmt=ecoff ;;
 
 # start-sanitize-arc
-  arc-*-elf*)          obj_format=elf bfd_gas=yes ;;
+      arc-*-elf*)           fmt=elf bfd_gas=yes ;;
 # end-sanitize-arc
 
-  arm-*-riscix*)       obj_format=aout ;;
-
-  hppa-*-*elf*)                obj_format=elf emulation=hppa ;;
-  hppa-*-lites*)       obj_format=elf emulation=hppa ;;
-  hppa-*-osf*)         obj_format=som emulation=hppa ;;
-  hppa-*-hpux*)                obj_format=som emulation=hppa ;;
-  hppa-*-bsd*)         obj_format=som emulation=hppa ;;
-  hppa-*-hiux*)                obj_format=som emulation=hppa ;;
-
-  h8300-*-coff)                obj_format=coff ;;
-
-  i386-ibm-aix*)       obj_format=coff gas_target=i386coff
-                        emulation=i386aix ;;
-  i386-*-bsd*)         obj_format=aout emulation=386bsd ;;
-  i386-*-netbsd0.8)    obj_format=aout emulation=386bsd ;;
-  i386-*-netbsd*)      obj_format=aout emulation=nbsd bfd_gas=yes;;
-  i386-*-linux*aout*)  obj_format=aout  emulation=linux ;;
-  i386-*-linux*coff*)  obj_format=coff emulation=linux
-                        gas_target=i386coff ;;
-  i386-*-linux*)       obj_format=elf emulation=linux ;;
-  i386-*-lynxos*)      obj_format=coff gas_target=i386coff
-                        emulation=lynx ;;
-  i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
-                       obj_format=elf ;;
-  i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
-                       obj_format=coff gas_target=i386coff ;;
-  i386-*-vsta)         obj_format=aout ;;
-  i386-*-go32)         obj_format=coff gas_target=i386coff ;;
-  i386-*-gnu*elf*)     obj_format=elf ;;
-  i386-*-mach* | i386-*-gnu*)
-                       obj_format=aout emulation=mach bfd_gas=yes ;;
-  i386-*-msdos*)       obj_format=aout ;;
-
-  i960-*-bout)         obj_format=bout ;;
-  i960-*-coff)         obj_format=coff emulation=ic960 gas_target=ic960coff ;;
-  i960-*-nindy*)       obj_format=bout ;;
-  i960-*-vxworks4*)    obj_format=bout ;;
-  i960-*-vxworks5.0)   obj_format=bout ;;
-  i960-*-vxworks5.*)   obj_format=coff emulation=ic960 gas_target=ic960coff ;;
-  i960-*-vxworks*)     obj_format=bout ;;
-
-  m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
-                       obj_format=aout emulation=sun3 ;;
-  m68k-motorola-sysv)  obj_format=coff gas_target=m68kcoff emulation=delta ;;
-  m68k-bull-sysv3*)    obj_format=coff gas_target=m68kcoff emulation=dpx2 ;;
-  m68k-apollo-*)       obj_format=coff gas_target=apollo emulation=apollo ;;
-  m68k-*-coff | m68k-*-sysv*)
-                       obj_format=coff gas_target=m68kcoff ;;
-  m68k-*-elf)          obj_format=elf ;;
-  m68k-*-hpux*)                obj_format=hp300 emulation=hp300 ;;
-  m68k-*-lynxos*)      obj_format=coff gas_target=m68kcoff
-                        emulation=lynx ;;
-  m68k-*-netbsd*)      obj_format=aout emulation=nbsd bfd_gas=yes ;;
-
-  m88k-*-coff*)                obj_format=coff gas_target=m88kcoff ;;
-
-  # don't change emulation like *-*-bsd does
-  mips-dec-bsd*)       obj_format=aout gas_target=mips-lit ;;
-  mips-sony-bsd*)      obj_format=ecoff gas_target=mips-big ;;
-  mips-*-bsd*)         { echo "configure: error: Unknown vendor for mips-bsd configuration." 1>&2; exit 1; } ;;
-  mips-*-ultrix*)      obj_format=ecoff gas_target=mips-lit ;;
-  mips-*-ecoff*)       obj_format=ecoff 
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  mips-*-ecoff*)       obj_format=ecoff gas_target=mips-big ;;
-  mips-*-gnu*)         obj_format=aout
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  mips-*-irix5*)       obj_format=elf gas_target=mips-big ;;
-  mips-*-irix*)                obj_format=ecoff gas_target=mips-big ;;
-  mips-*-riscos*)      obj_format=ecoff gas_target=mips-big ;;
-  mips-*-sysv*)                obj_format=ecoff gas_target=mips-big ;;
-  mips-*-elf*)         obj_format=elf 
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  ppc-*-aix*)          obj_format=coff ;;
-  ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
-                       obj_format=elf
-                       case "$endian" in
-                       big) gas_target=ppc-big ;;
-                       *)   gas_target=ppc-lit ;;
-                       esac
-                       ;;
-  ppc-*-netware*)      obj_format=elf emulation=ppcnw ;;
-
-  sh-*-coff)           obj_format=coff ;;
+      arm-*-riscix*)        fmt=aout ;;
+
+      hppa-*-*elf*)         fmt=elf em=hppa ;;
+      hppa-*-lites*)        fmt=elf em=hppa ;;
+      hppa-*-osf*)          fmt=som em=hppa ;;
+      hppa-*-hpux*)         fmt=som em=hppa ;;
+      hppa-*-bsd*)          fmt=som em=hppa ;;
+      hppa-*-hiux*)         fmt=som em=hppa ;;
+
+      h8300-*-coff)         fmt=coff ;;
+
+      i386-ibm-aix*)        fmt=coff targ=i386coff
+                            em=i386aix ;;
+      i386-*-bsd*)          fmt=aout em=386bsd ;;
+      i386-*-netbsd0.8)     fmt=aout em=386bsd ;;
+      i386-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes;;
+      i386-*-linux*aout*)   fmt=aout  em=linux ;;
+      i386-*-linux*coff*)   fmt=coff em=linux
+                            targ=i386coff ;;
+      i386-*-linux*)        fmt=elf em=linux ;;
+      i386-*-lynxos*)       fmt=coff targ=i386coff
+                            em=lynx ;;
+      i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
+                           fmt=elf ;;
+      i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
+                           fmt=coff targ=i386coff ;;
+      i386-*-vsta)          fmt=aout ;;
+      i386-*-go32)          fmt=coff targ=i386coff ;;
+      i386-*-gnu*elf*)      fmt=elf ;;
+      i386-*-mach* | i386-*-gnu*)
+                           fmt=aout em=mach bfd_gas=yes ;;
+      i386-*-msdos*)        fmt=aout ;;
+
+      i960-*-bout)          fmt=bout ;;
+      i960-*-coff)          fmt=coff em=ic960 targ=ic960coff ;;
+      i960-*-nindy*)        fmt=bout ;;
+      i960-*-vxworks4*)     fmt=bout ;;
+      i960-*-vxworks5.0)    fmt=bout ;;
+      i960-*-vxworks5.*)    fmt=coff em=ic960 targ=ic960coff ;;
+      i960-*-vxworks*)      fmt=bout ;;
+
+      m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
+                           fmt=aout em=sun3 ;;
+      m68k-motorola-sysv)   fmt=coff targ=m68kcoff em=delta ;;
+      m68k-bull-sysv3*)     fmt=coff targ=m68kcoff em=dpx2 ;;
+      m68k-apollo-*)        fmt=coff targ=apollo em=apollo ;;
+      m68k-*-coff | m68k-*-sysv*)
+                           fmt=coff targ=m68kcoff ;;
+      m68k-*-elf)           fmt=elf ;;
+      m68k-*-hpux*)         fmt=hp300 em=hp300 ;;
+      m68k-*-lynxos*)       fmt=coff targ=m68kcoff
+                            em=lynx ;;
+      m68k-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes ;;
+
+      m88k-*-coff*)         fmt=coff targ=m88kcoff ;;
+
+      # don't change em like *-*-bsd does
+      mips-dec-bsd*)        fmt=aout targ=mips-lit ;;
+      mips-sony-bsd*)       fmt=ecoff targ=mips-big ;;
+      mips-*-bsd*)          { echo "configure: error: Unknown vendor for mips-bsd configuration." 1>&2; exit 1; } ;;
+      mips-*-ultrix*)       fmt=ecoff targ=mips-lit ;;
+      mips-*-ecoff*)        fmt=ecoff 
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      mips-*-ecoff*)        fmt=ecoff targ=mips-big ;;
+      mips-*-gnu*)          fmt=aout
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      mips-*-irix5*)        fmt=elf targ=mips-big ;;
+      mips-*-irix*)         fmt=ecoff targ=mips-big ;;
+      mips-*-riscos*)       fmt=ecoff targ=mips-big ;;
+      mips-*-sysv*)         fmt=ecoff targ=mips-big ;;
+      mips-*-elf*)          fmt=elf 
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      ppc-*-aix*)           fmt=coff ;;
+      ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
+                           fmt=elf
+                           case "$endian" in
+                           big)  targ=ppc-big ;;
+                           *)    targ=ppc-lit ;;
+                           esac
+                           ;;
+      ppc-*-netware*)       fmt=elf em=ppcnw ;;
+
+      sh-*-coff)            fmt=coff ;;
 
 # start-sanitize-rce
-  rce-*-aout)          obj_format=aout ;;
+      rce-*-aout)           fmt=aout ;;
 # end-sanitize-rce
 
-  ns32k-pc532-mach*)   obj_format=aout emulation=pc532mach ;;
-  ns32k-pc532-netbsd*) obj_format=aout emulation=nbsd532 ;;
-
-  sparc-*-sunos4*)     obj_format=aout emulation=sun3 ;;
-  sparc-*-aout | sparc*-*-vxworks)
-                       obj_format=aout ;;
-  sparc-*-coff)                obj_format=coff ;;
-  sparc-*-lynxos*)     obj_format=coff emulation=lynx ;;
-  sparc-fujitsu-none)  obj_format=aout ;;
-  sparc-*-elf | sparc*-*-solaris*)
-                       obj_format=elf ;;
-  sparc-*-netbsd*)     obj_format=aout emulation=nbsd bfd_gas=yes ;;
-
-  vax-*-bsd* | vax-*-ultrix*)
-                       obj_format=aout ;;
-  vax-*-vms)           obj_format=vms ;;
-
-  z8k-*-coff | z8k-*-sim)
-                       obj_format=coff ;;
-
-  w65-*-*)             obj_format=coff ;;
-
-  *-*-aout | *-*-scout)
-                       obj_format=aout ;;
-  *-*-nindy*)
-                       obj_format=bout ;;
-  *-*-bsd*)
-                       obj_format=aout emulation=sun3 ;;
-  *-*-generic)         obj_format=generic ;;
-  *-*-xray | *-*-hms)  obj_format=coff ;;
-  *-*-sim)             obj_format=coff ;;
-  *-*-elf | *-*-sysv4* | *-*-solaris*)
-                       echo "configure: warning: GAS support for ELF format is incomplete" 1>&2
-                       obj_format=elf dev=yes ;;
-  *-*-vxworks)         obj_format=aout ;;
-  *-*-netware)         obj_format=elf ;;
-esac
+      ns32k-pc532-mach*)    fmt=aout em=pc532mach ;;
+      ns32k-pc532-netbsd*)  fmt=aout em=nbsd532 ;;
+
+      sparc-*-sunos4*)      fmt=aout em=sun3 ;;
+      sparc-*-aout | sparc*-*-vxworks)
+                           fmt=aout ;;
+      sparc-*-coff)         fmt=coff ;;
+      sparc-*-lynxos*)      fmt=coff em=lynx ;;
+      sparc-fujitsu-none)   fmt=aout ;;
+      sparc-*-elf | sparc*-*-solaris*)
+                           fmt=elf ;;
+      sparc-*-netbsd*)      fmt=aout em=nbsd bfd_gas=yes ;;
+
+      vax-*-bsd* | vax-*-ultrix*)
+                           fmt=aout ;;
+      vax-*-vms)            fmt=vms ;;
+
+      z8k-*-coff | z8k-*-sim)
+                           fmt=coff ;;
+
+      w65-*-*)              fmt=coff ;;
+
+      *-*-aout | *-*-scout)
+                           fmt=aout ;;
+      *-*-nindy*)
+                           fmt=bout ;;
+      *-*-bsd*)
+                           fmt=aout em=sun3 ;;
+      *-*-generic)          fmt=generic ;;
+      *-*-xray | *-*-hms)   fmt=coff ;;
+      *-*-sim)              fmt=coff ;;
+      *-*-elf | *-*-sysv4* | *-*-solaris*)
+                           echo "configure: warning: GAS support for ELF format is incomplete." 1>&2
+                           fmt=elf dev=yes ;;
+      *-*-vxworks)          fmt=aout ;;
+      *-*-netware)          fmt=elf ;;
+    esac
+
+    case ${cpu_type}-${fmt} in
+      arm-*)   bfd_gas=yes ;;
+    # not yet
+    # i386-aout)       bfd_gas=preferred ;;
+      mips-*)  bfd_gas=yes ;;
+      ns32k-*) bfd_gas=yes ;;
+      ppc-*)   bfd_gas=yes ;;
+      sparc-*) bfd_gas=yes ;;
+      *-elf)   bfd_gas=yes ;;
+      *-ecoff) bfd_gas=yes ;;
+      *-som)   bfd_gas=yes ;;
+      *)               ;;
+    esac
+
+# See if we really can support this configuration with the emulation code.
+
+    if test $this_target = $target ; then
+      primary_bfd_gas=$bfd_gas
+      obj_format=$fmt
+      gas_target=$targ
+      te_file=$em
+
+      if test $bfd_gas = no ; then
+       # Can't support other configurations this way.
+       break
+      fi
+    elif test $bfd_gas = no ; then
+      # Can't support this configuration.
+      break
+    fi
+
+# From target name and format, produce a list of supported emulations.
+
+    case ${generic_target}-${fmt} in
+      mips-*-irix5*-*) emulation="mipsbelf mipslelf mipsbecoff mipslecoff" ;;
+      mips-*-*-ecoff)  case "$endian" in
+                       big)    emulation="mipsbecoff mipslecoff" ;;
+                       *)      emulation="mipslecoff mipsbecoff" ;;
+                       esac ;;
+      mips-*-*-elf)    case "$endian" in
+                       big)    emulation="mipsbelf mipslelf" ;;
+                       *)      emulation="mipslelf mipsbelf" ;;
+                       esac ;;
+    esac
+
+    emulations="$emulations $emulation"
+
+# Other random stuff.
+
+    test -n "$want_sparcv9" && cat >> confdefs.h <<\EOF
+#define sparcv9 1
+EOF
+
+
+done
 
 # Assign floating point type.  Most processors with FP support
 # IEEE FP.  On those that don't support FP at all, usually IEEE
 # is emulated.
 case ${target_cpu} in
   vax | tahoe )        atof=${target_cpu} ;;
-  *)                   atof=ieee ;;
+  *)           atof=ieee ;;
 esac
 
 case "${obj_format}" in
@@ -757,21 +884,7 @@ if test ! -r ${target_frag}; then
 fi
 
 
-case ${cpu_type}-${obj_format} in
-  arm-*)       bfd_gas=yes ;;
-# not yet
-# i386-aout)   bfd_gas=preferred ;;
-  mips-*)      bfd_gas=yes ;;
-  ns32k-*)     bfd_gas=yes ;;
-  ppc-*)       bfd_gas=yes ;;
-  sparc-*)     bfd_gas=yes ;;
-  *-elf)       bfd_gas=yes ;;
-  *-ecoff)     bfd_gas=yes ;;
-  *-som)       bfd_gas=yes ;;
-  *)           ;;
-esac
-
-case ${user_bfd_gas}-${bfd_gas} in
+case ${user_bfd_gas}-${primary_bfd_gas} in
   yes-yes | no-no)
     # We didn't override user's choice.
     ;;
@@ -779,20 +892,180 @@ case ${user_bfd_gas}-${bfd_gas} in
     echo "configure: warning: Use of BFD is required for ${target}; overriding config options." 1>&2
     ;;
   no-preferred)
-    bfd_gas=no
+    primary_bfd_gas=no
     ;;
   *-preferred)
-    bfd_gas=yes
+    primary_bfd_gas=yes
     ;;
   yes-*)
-    bfd_gas=yes
+    primary_bfd_gas=yes
     ;;
   -*)
     # User specified nothing.
     ;;
 esac
 
-case ${bfd_gas}-${cpu_type}-${obj_format} in
+# Some COFF configurations want these random other flags set.
+case ${obj_format} in
+  coff)
+    case ${target_cpu_type} in
+      i386) cat >> confdefs.h <<\EOF
+#define I386COFF 1
+EOF
+ ;;
+      m68k) cat >> confdefs.h <<\EOF
+#define M68KCOFF 1
+EOF
+ ;;
+      m88k) cat >> confdefs.h <<\EOF
+#define M88KCOFF 1
+EOF
+ ;;
+    esac
+    ;;
+esac
+
+# Getting this done right is going to be a bitch.  Each configuration specified
+# with --enable-targets=... should be checked for environment, format, cpu, and
+# bfd_gas setting.
+#
+# For each configuration, the necessary object file support code must be linked
+# in.  This might be only one, it might be up to four.  The necessary emulation
+# code needs to be provided, too.
+#
+# And then there's "--enable-targets=all"....
+#
+# For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
+
+formats="${obj_format}"
+emfiles=""
+EMULATIONS=""
+_gas_uniq_list="$emulations"
+_gas_uniq_newlist=""
+for _gas_uniq_i in _gas_uniq_dummy $_gas_uniq_list ; do
+  case $_gas_uniq_i in
+  _gas_uniq_dummy) ;;
+  *) case " $_gas_uniq_newlist " in
+       *" $_gas_uniq_i "*) ;;
+       *) _gas_uniq_newlist="$_gas_uniq_newlist $_gas_uniq_i" ;;
+     esac ;;
+  esac
+done
+emulations=$_gas_uniq_newlist
+
+for em in . $emulations ; do
+  case $em in
+    .) continue ;;
+    mipsbelf | mipslelf)
+       fmt=elf   file=mipself ;;
+    mipsbecoff | mipslecoff)
+       fmt=ecoff file=mipsecoff ;;
+  esac
+  formats="$formats $fmt"
+  emfiles="$emfiles e-$file.o"
+  EMULATIONS="$EMULATIONS &$em,"
+done
+_gas_uniq_list="$formats"
+_gas_uniq_newlist=""
+for _gas_uniq_i in _gas_uniq_dummy $_gas_uniq_list ; do
+  case $_gas_uniq_i in
+  _gas_uniq_dummy) ;;
+  *) case " $_gas_uniq_newlist " in
+       *" $_gas_uniq_i "*) ;;
+       *) _gas_uniq_newlist="$_gas_uniq_newlist $_gas_uniq_i" ;;
+     esac ;;
+  esac
+done
+formats=$_gas_uniq_newlist
+
+_gas_uniq_list="$emfiles"
+_gas_uniq_newlist=""
+for _gas_uniq_i in _gas_uniq_dummy $_gas_uniq_list ; do
+  case $_gas_uniq_i in
+  _gas_uniq_dummy) ;;
+  *) case " $_gas_uniq_newlist " in
+       *" $_gas_uniq_i "*) ;;
+       *) _gas_uniq_newlist="$_gas_uniq_newlist $_gas_uniq_i" ;;
+     esac ;;
+  esac
+done
+emfiles=$_gas_uniq_newlist
+
+if test `set . $formats ; shift ; echo $#` -gt 1 ; then
+  for fmt in $formats ; do
+    case $fmt in
+      aout)    cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_AOUT 1
+EOF
+    ;;
+      bout)    cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_BOUT 1
+EOF
+    ;;
+      coff)    cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_COFF 1
+EOF
+    ;;
+      ecoff)   cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_ECOFF 1
+EOF
+   ;;
+      elf)     cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_ELF 1
+EOF
+     ;;
+      generic) cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_GENERIC 1
+EOF
+ ;;
+      hp300)   cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_HP300 1
+EOF
+   ;;
+      ieee)    cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_IEEE 1
+EOF
+    ;;
+      som)     cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_SOM 1
+EOF
+     ;;
+      vms)     cat >> confdefs.h <<\EOF
+#define OBJ_MAYBE_VMS 1
+EOF
+     ;;
+    esac
+    extra_objects="$extra_objects obj-$fmt.o"
+  done
+  obj_format=multi
+fi
+if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
+  te_file=multi
+  extra_objects="$extra_objects $emfiles"
+  DEFAULT_EMULATION=`set . $emulations ; echo $2`
+  cat >> confdefs.h <<\EOF
+#define USE_EMULATIONS 1
+EOF
+
+fi
+
+cat >> confdefs.h <<EOF
+#define EMULATIONS $EMULATIONS
+EOF
+
+cat >> confdefs.h <<EOF
+#define DEFAULT_EMULATION "$DEFAULT_EMULATION"
+EOF
+
+
+files="config/tc-${cpu_type}.c config/tc-${cpu_type}.h \
+       config/obj-${obj_format}.h config/obj-${obj_format}.c \
+       config/te-${te_file}.h config/atof-${atof}.c \
+       $extra_files"
+links="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c \
+       $extra_links"
+
+case ${primary_bfd_gas}-${cpu_type}-${obj_format} in
   yes-*-coff)  need_bfd=yes ;;
   no-*-coff)   need_bfd=yes
                cat >> confdefs.h <<\EOF
@@ -815,8 +1088,7 @@ esac
 
 
 
-
-case "${bfd_gas}" in
+case "${primary_bfd_gas}" in
   yes) cat >> confdefs.h <<\EOF
 #define BFD_ASSEMBLER 1
 EOF
@@ -940,7 +1212,7 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 944 "configure"
+#line 1216 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -954,7 +1226,7 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 958 "configure"
+#line 1230 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
@@ -985,7 +1257,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 989 "configure"
+#line 1261 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
@@ -1037,7 +1309,7 @@ else
   ac_cv_c_cross=yes
 else
 cat > conftest.$ac_ext <<EOF
-#line 1041 "configure"
+#line 1313 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
@@ -1060,7 +1332,7 @@ if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1064 "configure"
+#line 1336 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() { return 0; }
@@ -1091,7 +1363,7 @@ if eval "test \"`echo '$''{'ac_cv_func_alloca'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1095 "configure"
+#line 1367 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -1149,7 +1421,7 @@ if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1153 "configure"
+#line 1425 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -1177,7 +1449,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1181 "configure"
+#line 1453 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1231,7 +1503,7 @@ else
   ac_cv_c_stack_direction=0
 else
 cat > conftest.$ac_ext <<EOF
-#line 1235 "configure"
+#line 1507 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -1273,7 +1545,7 @@ else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 1277 "configure"
+#line 1549 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1312,7 +1584,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1316 "configure"
+#line 1588 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1365,7 +1637,7 @@ if eval "test \"`echo '$''{'gas_cv_assert_ok'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1369 "configure"
+#line 1641 "configure"
 #include "confdefs.h"
 #include <assert.h>
 #include <stdio.h>
@@ -1422,7 +1694,7 @@ if eval "test \"`echo '$''{'gas_cv_decl_needed_malloc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1426 "configure"
+#line 1698 "configure"
 #include "confdefs.h"
 $gas_test_headers
 int main() { return 0; }
@@ -1458,7 +1730,7 @@ if eval "test \"`echo '$''{'gas_cv_decl_needed_free'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1462 "configure"
+#line 1734 "configure"
 #include "confdefs.h"
 $gas_test_headers
 int main() { return 0; }
@@ -1497,7 +1769,7 @@ if eval "test \"`echo '$''{'gas_cv_decl_needed_errno'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1501 "configure"
+#line 1773 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_ERRNO_H
@@ -1656,10 +1928,10 @@ s%@build_os@%$build_os%g
 s%@OPCODES_LIB@%$OPCODES_LIB%g
 /@target_frag@/r $target_frag
 s%@target_frag@%%g
+s%@extra_objects@%$extra_objects%g
 s%@cpu_type@%$cpu_type%g
 s%@obj_format@%$obj_format%g
 s%@atof@%$atof%g
-s%@emulation@%$emulation%g
 s%@BFDLIB@%$BFDLIB%g
 s%@ALL_OBJ_DEPS@%$ALL_OBJ_DEPS%g
 s%@CC@%$CC%g
@@ -1828,10 +2100,8 @@ fi; done
 EOF
 
 cat >> $CONFIG_STATUS <<EOF
-ac_sources="config/tc-${cpu_type}.c    config/tc-${cpu_type}.h \
-       config/obj-${obj_format}.h config/obj-${obj_format}.c \
-       config/te-${emulation}.h config/atof-${atof}.c"
-ac_dests="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c"
+ac_sources="$files"
+ac_dests="$links"
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
index 82ee49129f3ab16e8e9631e91d15fed061682086..aa846ef1d34a79d877fb7dc2637b19616ea5532d 100644 (file)
@@ -7,7 +7,6 @@ dnl
 AC_PREREQ(2.3)dnl We only need 2.0, but pre-2.3 loses on some AIX version.
 AC_INIT(as.h)dnl
 dnl
-bfd_gas=no
 user_bfd_gas=
 AC_ARG_ENABLE(bfd-assembler,
 [    bfd-assembler     use BFD back end for writing object files],
@@ -16,6 +15,14 @@ AC_ARG_ENABLE(bfd-assembler,
   no)  user_bfd_gas=no ;;
   *)   AC_MSG_ERROR(bad value ${enableval} given for bfd-assembler option) ;;
 esac])dnl
+AC_ARG_ENABLE(targets,
+[    targets            alternative target configurations besides the primary],
+[case "${enableval}" in
+  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
+           ;;
+  no)      enable_targets= ;;
+  *)       enable_targets=$enableval ;;
+esac])dnl
 
 # Generate a header file -- gets more post-processing by Makefile later.
 AC_CONFIG_HEADER(conf)
@@ -25,7 +32,7 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
 AC_CANONICAL_SYSTEM
 AC_ARG_PROGRAM
 
-emulation=generic
+te_file=generic
 
 # assign cpu type
 
@@ -41,8 +48,8 @@ changequote([,])dnl
   m8*)         cpu_type=m88k ;;
   mips*el)     cpu_type=mips endian=little;;
   mips*)       cpu_type=mips endian=big ;;
-  powerpcle*)  cpu_type=ppc endian=little;;
-  powerpc*)    cpu_type=ppc endian=big;;
+  powerpcle*)  cpu_type=ppc endian=little ;;
+  powerpc*)    cpu_type=ppc endian=big ;;
   rs6000*)     cpu_type=ppc ;;
   sparc64)     cpu_type=sparc obj_format=elf
                AC_DEFINE(sparcv9) ;;
@@ -61,166 +68,270 @@ esac
 AC_SUBST(OPCODES_LIB)
 
 gas_target=${cpu_type}
-generic_target=${cpu_type}-${target_vendor}-${target_os}
-dev=no
+this_target=${generic_target}
+
+canon_targets=""
+if test -n "$enable_targets" ; then
+  for t in `echo $enable_targets | sed 's/,/ /g'`; do
+    result=`$ac_config_sub $t 2>/dev/null`
+    if test -n "$result" ; then
+      canon_targets="$canon_targets $result"
+#    else
+#      # Permit "all", etc.  We don't support it yet though.
+#      canon_targets="$canon_targets $t"
+    fi
+  done
+  GAS_UNIQ(canon_targets)
+fi
+
+emulations=""
+
+for this_target in $target $canon_targets ; do
+
+    eval `echo $this_target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
 
-# assign object format
-case ${generic_target} in
-  a29k-amd-udi)                obj_format=coff gas_target=ebmon29k ;;
-  a29k-amd-ebmon)      obj_format=coff gas_target=ebmon29k ;;
-  a29k-*-vxworks*)      obj_format=coff ;;
+    # check for architecture variants
+    case ${cpu} in
+      hppa*)           cpu_type=hppa ;;
+changequote(,)dnl
+      i[45]86)         cpu_type=i386 ;;
+      m680[012346]0)   cpu_type=m68k ;;
+      m68008)          cpu_type=m68k ;;
+      m683??)          cpu_type=m68k ;;
+changequote([,])dnl
+      m8*)             cpu_type=m88k ;;
+      mips*el)         cpu_type=mips endian=little;;
+      mips*)           cpu_type=mips endian=big ;;
+      powerpcle*)      cpu_type=ppc endian=little ;;
+      powerpc*)                cpu_type=ppc endian=big ;;
+      rs6000*)         cpu_type=ppc ;;
+      sparc64)         cpu_type=sparc obj_format=elf want_sparcv9=true ;;
+      sparclite*)      cpu_type=sparc ;;
+      *)               cpu_type=${target_cpu} ;;
+    esac
+
+    if test ${this_target} = $target ; then
+      target_cpu_type=${cpu_type}
+    elif test ${target_cpu_type} != ${cpu_type} ; then
+      continue
+    fi
+
+    targ=${cpu_type}
+    generic_target=${cpu_type}-$vendor-$os
+    dev=no
+    bfd_gas=no
+    em=generic
 
-  alpha-*-netware*)    obj_format=ecoff ;;
-  alpha-*-osf*)                obj_format=ecoff ;;
+    # assign object format
+    case ${generic_target} in
+      a29k-amd-udi)         fmt=coff targ=ebmon29k ;;
+      a29k-amd-ebmon)       fmt=coff targ=ebmon29k ;;
+      a29k-*-vxworks*)      fmt=coff ;;
+
+      alpha-*-netware*)     fmt=ecoff ;;
+      alpha-*-osf*)         fmt=ecoff ;;
 
 # start-sanitize-arc
-  arc-*-elf*)          obj_format=elf bfd_gas=yes ;;
+      arc-*-elf*)           fmt=elf bfd_gas=yes ;;
 # end-sanitize-arc
 
-  arm-*-riscix*)       obj_format=aout ;;
-
-  hppa-*-*elf*)                obj_format=elf emulation=hppa ;;
-  hppa-*-lites*)       obj_format=elf emulation=hppa ;;
-  hppa-*-osf*)         obj_format=som emulation=hppa ;;
-  hppa-*-hpux*)                obj_format=som emulation=hppa ;;
-  hppa-*-bsd*)         obj_format=som emulation=hppa ;;
-  hppa-*-hiux*)                obj_format=som emulation=hppa ;;
-
-  h8300-*-coff)                obj_format=coff ;;
-
-  i386-ibm-aix*)       obj_format=coff gas_target=i386coff
-                        emulation=i386aix ;;
-  i386-*-bsd*)         obj_format=aout emulation=386bsd ;;
-  i386-*-netbsd0.8)    obj_format=aout emulation=386bsd ;;
-  i386-*-netbsd*)      obj_format=aout emulation=nbsd bfd_gas=yes;;
-  i386-*-linux*aout*)  obj_format=aout  emulation=linux ;;
-  i386-*-linux*coff*)  obj_format=coff emulation=linux
-                        gas_target=i386coff ;;
-  i386-*-linux*)       obj_format=elf emulation=linux ;;
-  i386-*-lynxos*)      obj_format=coff gas_target=i386coff
-                        emulation=lynx ;;
-  i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
-                       obj_format=elf ;;
-  i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
-                       obj_format=coff gas_target=i386coff ;;
-  i386-*-vsta)         obj_format=aout ;;
-  i386-*-go32)         obj_format=coff gas_target=i386coff ;;
-  i386-*-gnu*elf*)     obj_format=elf ;;
-  i386-*-mach* | i386-*-gnu*)
-                       obj_format=aout emulation=mach bfd_gas=yes ;;
-  i386-*-msdos*)       obj_format=aout ;;
-
-  i960-*-bout)         obj_format=bout ;;
-  i960-*-coff)         obj_format=coff emulation=ic960 gas_target=ic960coff ;;
-  i960-*-nindy*)       obj_format=bout ;;
-  i960-*-vxworks4*)    obj_format=bout ;;
-  i960-*-vxworks5.0)   obj_format=bout ;;
-  i960-*-vxworks5.*)   obj_format=coff emulation=ic960 gas_target=ic960coff ;;
-  i960-*-vxworks*)     obj_format=bout ;;
-
-  m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
-                       obj_format=aout emulation=sun3 ;;
-  m68k-motorola-sysv)  obj_format=coff gas_target=m68kcoff emulation=delta ;;
-  m68k-bull-sysv3*)    obj_format=coff gas_target=m68kcoff emulation=dpx2 ;;
-  m68k-apollo-*)       obj_format=coff gas_target=apollo emulation=apollo ;;
-  m68k-*-coff | m68k-*-sysv*)
-                       obj_format=coff gas_target=m68kcoff ;;
-  m68k-*-elf)          obj_format=elf ;;
-  m68k-*-hpux*)                obj_format=hp300 emulation=hp300 ;;
-  m68k-*-lynxos*)      obj_format=coff gas_target=m68kcoff
-                        emulation=lynx ;;
-  m68k-*-netbsd*)      obj_format=aout emulation=nbsd bfd_gas=yes ;;
-
-  m88k-*-coff*)                obj_format=coff gas_target=m88kcoff ;;
-
-  # don't change emulation like *-*-bsd does
-  mips-dec-bsd*)       obj_format=aout gas_target=mips-lit ;;
-  mips-sony-bsd*)      obj_format=ecoff gas_target=mips-big ;;
-  mips-*-bsd*)         AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
-  mips-*-ultrix*)      obj_format=ecoff gas_target=mips-lit ;;
-  mips-*-ecoff*)       obj_format=ecoff 
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  mips-*-ecoff*)       obj_format=ecoff gas_target=mips-big ;;
-  mips-*-gnu*)         obj_format=aout
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  mips-*-irix5*)       obj_format=elf gas_target=mips-big ;;
-  mips-*-irix*)                obj_format=ecoff gas_target=mips-big ;;
-  mips-*-riscos*)      obj_format=ecoff gas_target=mips-big ;;
-  mips-*-sysv*)                obj_format=ecoff gas_target=mips-big ;;
-  mips-*-elf*)         obj_format=elf 
-                       case "$endian" in
-                       big) gas_target=mips-big ;;
-                       *)   gas_target=mips-lit ;;
-                       esac
-                       ;;
-  ppc-*-aix*)          obj_format=coff ;;
-  ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
-                       obj_format=elf
-                       case "$endian" in
-                       big) gas_target=ppc-big ;;
-                       *)   gas_target=ppc-lit ;;
-                       esac
-                       ;;
-  ppc-*-netware*)      obj_format=elf emulation=ppcnw ;;
-
-  sh-*-coff)           obj_format=coff ;;
+      arm-*-riscix*)        fmt=aout ;;
+
+      hppa-*-*elf*)         fmt=elf em=hppa ;;
+      hppa-*-lites*)        fmt=elf em=hppa ;;
+      hppa-*-osf*)          fmt=som em=hppa ;;
+      hppa-*-hpux*)         fmt=som em=hppa ;;
+      hppa-*-bsd*)          fmt=som em=hppa ;;
+      hppa-*-hiux*)         fmt=som em=hppa ;;
+
+      h8300-*-coff)         fmt=coff ;;
+
+      i386-ibm-aix*)        fmt=coff targ=i386coff
+                            em=i386aix ;;
+      i386-*-bsd*)          fmt=aout em=386bsd ;;
+      i386-*-netbsd0.8)     fmt=aout em=386bsd ;;
+      i386-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes;;
+      i386-*-linux*aout*)   fmt=aout  em=linux ;;
+      i386-*-linux*coff*)   fmt=coff em=linux
+                            targ=i386coff ;;
+      i386-*-linux*)        fmt=elf em=linux ;;
+      i386-*-lynxos*)       fmt=coff targ=i386coff
+                            em=lynx ;;
+      i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
+                           fmt=elf ;;
+      i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
+                           fmt=coff targ=i386coff ;;
+      i386-*-vsta)          fmt=aout ;;
+      i386-*-go32)          fmt=coff targ=i386coff ;;
+      i386-*-gnu*elf*)      fmt=elf ;;
+      i386-*-mach* | i386-*-gnu*)
+                           fmt=aout em=mach bfd_gas=yes ;;
+      i386-*-msdos*)        fmt=aout ;;
+
+      i960-*-bout)          fmt=bout ;;
+      i960-*-coff)          fmt=coff em=ic960 targ=ic960coff ;;
+      i960-*-nindy*)        fmt=bout ;;
+      i960-*-vxworks4*)     fmt=bout ;;
+      i960-*-vxworks5.0)    fmt=bout ;;
+      i960-*-vxworks5.*)    fmt=coff em=ic960 targ=ic960coff ;;
+      i960-*-vxworks*)      fmt=bout ;;
+
+      m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
+                           fmt=aout em=sun3 ;;
+      m68k-motorola-sysv)   fmt=coff targ=m68kcoff em=delta ;;
+      m68k-bull-sysv3*)     fmt=coff targ=m68kcoff em=dpx2 ;;
+      m68k-apollo-*)        fmt=coff targ=apollo em=apollo ;;
+      m68k-*-coff | m68k-*-sysv*)
+                           fmt=coff targ=m68kcoff ;;
+      m68k-*-elf)           fmt=elf ;;
+      m68k-*-hpux*)         fmt=hp300 em=hp300 ;;
+      m68k-*-lynxos*)       fmt=coff targ=m68kcoff
+                            em=lynx ;;
+      m68k-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes ;;
+
+      m88k-*-coff*)         fmt=coff targ=m88kcoff ;;
+
+      # don't change em like *-*-bsd does
+      mips-dec-bsd*)        fmt=aout targ=mips-lit ;;
+      mips-sony-bsd*)       fmt=ecoff targ=mips-big ;;
+      mips-*-bsd*)          AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
+      mips-*-ultrix*)       fmt=ecoff targ=mips-lit ;;
+      mips-*-ecoff*)        fmt=ecoff 
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      mips-*-ecoff*)        fmt=ecoff targ=mips-big ;;
+      mips-*-gnu*)          fmt=aout
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      mips-*-irix5*)        fmt=elf targ=mips-big ;;
+      mips-*-irix*)         fmt=ecoff targ=mips-big ;;
+      mips-*-riscos*)       fmt=ecoff targ=mips-big ;;
+      mips-*-sysv*)         fmt=ecoff targ=mips-big ;;
+      mips-*-elf*)          fmt=elf 
+                           case "$endian" in
+                           big) targ=mips-big ;;
+                           *)   targ=mips-lit ;;
+                           esac
+                           ;;
+      ppc-*-aix*)           fmt=coff ;;
+      ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
+                           fmt=elf
+                           case "$endian" in
+                           big)  targ=ppc-big ;;
+                           *)    targ=ppc-lit ;;
+                           esac
+                           ;;
+      ppc-*-netware*)       fmt=elf em=ppcnw ;;
+
+      sh-*-coff)            fmt=coff ;;
 
 # start-sanitize-rce
-  rce-*-aout)          obj_format=aout ;;
+      rce-*-aout)           fmt=aout ;;
 # end-sanitize-rce
 
-  ns32k-pc532-mach*)   obj_format=aout emulation=pc532mach ;;
-  ns32k-pc532-netbsd*) obj_format=aout emulation=nbsd532 ;;
-
-  sparc-*-sunos4*)     obj_format=aout emulation=sun3 ;;
-  sparc-*-aout | sparc*-*-vxworks)
-                       obj_format=aout ;;
-  sparc-*-coff)                obj_format=coff ;;
-  sparc-*-lynxos*)     obj_format=coff emulation=lynx ;;
-  sparc-fujitsu-none)  obj_format=aout ;;
-  sparc-*-elf | sparc*-*-solaris*)
-                       obj_format=elf ;;
-  sparc-*-netbsd*)     obj_format=aout emulation=nbsd bfd_gas=yes ;;
-
-  vax-*-bsd* | vax-*-ultrix*)
-                       obj_format=aout ;;
-  vax-*-vms)           obj_format=vms ;;
-
-  z8k-*-coff | z8k-*-sim)
-                       obj_format=coff ;;
-
-  w65-*-*)             obj_format=coff ;;
-
-  *-*-aout | *-*-scout)
-                       obj_format=aout ;;
-  *-*-nindy*)
-                       obj_format=bout ;;
-  *-*-bsd*)
-                       obj_format=aout emulation=sun3 ;;
-  *-*-generic)         obj_format=generic ;;
-  *-*-xray | *-*-hms)  obj_format=coff ;;
-  *-*-sim)             obj_format=coff ;;
-  *-*-elf | *-*-sysv4* | *-*-solaris*)
-                       AC_MSG_WARN(GAS support for ELF format is incomplete)
-                       obj_format=elf dev=yes ;;
-  *-*-vxworks)         obj_format=aout ;;
-  *-*-netware)         obj_format=elf ;;
-esac
+      ns32k-pc532-mach*)    fmt=aout em=pc532mach ;;
+      ns32k-pc532-netbsd*)  fmt=aout em=nbsd532 ;;
+
+      sparc-*-sunos4*)      fmt=aout em=sun3 ;;
+      sparc-*-aout | sparc*-*-vxworks)
+                           fmt=aout ;;
+      sparc-*-coff)         fmt=coff ;;
+      sparc-*-lynxos*)      fmt=coff em=lynx ;;
+      sparc-fujitsu-none)   fmt=aout ;;
+      sparc-*-elf | sparc*-*-solaris*)
+                           fmt=elf ;;
+      sparc-*-netbsd*)      fmt=aout em=nbsd bfd_gas=yes ;;
+
+      vax-*-bsd* | vax-*-ultrix*)
+                           fmt=aout ;;
+      vax-*-vms)            fmt=vms ;;
+
+      z8k-*-coff | z8k-*-sim)
+                           fmt=coff ;;
+
+      w65-*-*)              fmt=coff ;;
+
+      *-*-aout | *-*-scout)
+                           fmt=aout ;;
+      *-*-nindy*)
+                           fmt=bout ;;
+      *-*-bsd*)
+                           fmt=aout em=sun3 ;;
+      *-*-generic)          fmt=generic ;;
+      *-*-xray | *-*-hms)   fmt=coff ;;
+      *-*-sim)              fmt=coff ;;
+      *-*-elf | *-*-sysv4* | *-*-solaris*)
+                           AC_MSG_WARN(GAS support for ELF format is incomplete.)
+                           fmt=elf dev=yes ;;
+      *-*-vxworks)          fmt=aout ;;
+      *-*-netware)          fmt=elf ;;
+    esac
+
+    case ${cpu_type}-${fmt} in
+      arm-*)   bfd_gas=yes ;;
+    # not yet
+    # i386-aout)       bfd_gas=preferred ;;
+      mips-*)  bfd_gas=yes ;;
+      ns32k-*) bfd_gas=yes ;;
+      ppc-*)   bfd_gas=yes ;;
+      sparc-*) bfd_gas=yes ;;
+      *-elf)   bfd_gas=yes ;;
+      *-ecoff) bfd_gas=yes ;;
+      *-som)   bfd_gas=yes ;;
+      *)               ;;
+    esac
+
+# See if we really can support this configuration with the emulation code.
+
+    if test $this_target = $target ; then
+      primary_bfd_gas=$bfd_gas
+      obj_format=$fmt
+      gas_target=$targ
+      te_file=$em
+
+      if test $bfd_gas = no ; then
+       # Can't support other configurations this way.
+       break
+      fi
+    elif test $bfd_gas = no ; then
+      # Can't support this configuration.
+      break
+    fi
+
+# From target name and format, produce a list of supported emulations.
+
+    case ${generic_target}-${fmt} in
+      mips-*-irix5*-*) emulation="mipsbelf mipslelf mipsbecoff mipslecoff" ;;
+      mips-*-*-ecoff)  case "$endian" in
+                       big)    emulation="mipsbecoff mipslecoff" ;;
+                       *)      emulation="mipslecoff mipsbecoff" ;;
+                       esac ;;
+      mips-*-*-elf)    case "$endian" in
+                       big)    emulation="mipsbelf mipslelf" ;;
+                       *)      emulation="mipslelf mipsbelf" ;;
+                       esac ;;
+    esac
+
+    emulations="$emulations $emulation"
+
+# Other random stuff.
+
+    test -n "$want_sparcv9" && AC_DEFINE(sparcv9)
+
+done
 
 # Assign floating point type.  Most processors with FP support
 # IEEE FP.  On those that don't support FP at all, usually IEEE
 # is emulated.
 case ${target_cpu} in
   vax | tahoe )        atof=${target_cpu} ;;
-  *)                   atof=ieee ;;
+  *)           atof=ieee ;;
 esac
 
 case "${obj_format}" in
@@ -247,21 +358,7 @@ if test ! -r ${target_frag}; then
 fi
 AC_SUBST_FILE(target_frag)
 
-case ${cpu_type}-${obj_format} in
-  arm-*)       bfd_gas=yes ;;
-# not yet
-# i386-aout)   bfd_gas=preferred ;;
-  mips-*)      bfd_gas=yes ;;
-  ns32k-*)     bfd_gas=yes ;;
-  ppc-*)       bfd_gas=yes ;;
-  sparc-*)     bfd_gas=yes ;;
-  *-elf)       bfd_gas=yes ;;
-  *-ecoff)     bfd_gas=yes ;;
-  *-som)       bfd_gas=yes ;;
-  *)           ;;
-esac
-
-case ${user_bfd_gas}-${bfd_gas} in
+case ${user_bfd_gas}-${primary_bfd_gas} in
   yes-yes | no-no)
     # We didn't override user's choice.
     ;;
@@ -269,20 +366,96 @@ case ${user_bfd_gas}-${bfd_gas} in
     AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
     ;;
   no-preferred)
-    bfd_gas=no
+    primary_bfd_gas=no
     ;;
   *-preferred)
-    bfd_gas=yes
+    primary_bfd_gas=yes
     ;;
   yes-*)
-    bfd_gas=yes
+    primary_bfd_gas=yes
     ;;
   -*)
     # User specified nothing.
     ;;
 esac
 
-case ${bfd_gas}-${cpu_type}-${obj_format} in
+# Some COFF configurations want these random other flags set.
+case ${obj_format} in
+  coff)
+    case ${target_cpu_type} in
+      i386) AC_DEFINE(I386COFF) ;;
+      m68k) AC_DEFINE(M68KCOFF) ;;
+      m88k) AC_DEFINE(M88KCOFF) ;;
+    esac
+    ;;
+esac
+
+# Getting this done right is going to be a bitch.  Each configuration specified
+# with --enable-targets=... should be checked for environment, format, cpu, and
+# bfd_gas setting.
+#
+# For each configuration, the necessary object file support code must be linked
+# in.  This might be only one, it might be up to four.  The necessary emulation
+# code needs to be provided, too.
+#
+# And then there's "--enable-targets=all"....
+#
+# For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
+
+formats="${obj_format}"
+emfiles=""
+EMULATIONS=""
+GAS_UNIQ(emulations)
+for em in . $emulations ; do
+  case $em in
+    .) continue ;;
+    mipsbelf | mipslelf)
+       fmt=elf   file=mipself ;;
+    mipsbecoff | mipslecoff)
+       fmt=ecoff file=mipsecoff ;;
+  esac
+  formats="$formats $fmt"
+  emfiles="$emfiles e-$file.o"
+  EMULATIONS="$EMULATIONS &$em,"
+done
+GAS_UNIQ(formats)
+GAS_UNIQ(emfiles)
+if test `set . $formats ; shift ; echo $#` -gt 1 ; then
+  for fmt in $formats ; do
+    case $fmt in
+      aout)    AC_DEFINE(OBJ_MAYBE_AOUT)    ;;
+      bout)    AC_DEFINE(OBJ_MAYBE_BOUT)    ;;
+      coff)    AC_DEFINE(OBJ_MAYBE_COFF)    ;;
+      ecoff)   AC_DEFINE(OBJ_MAYBE_ECOFF)   ;;
+      elf)     AC_DEFINE(OBJ_MAYBE_ELF)     ;;
+      generic) AC_DEFINE(OBJ_MAYBE_GENERIC) ;;
+      hp300)   AC_DEFINE(OBJ_MAYBE_HP300)   ;;
+      ieee)    AC_DEFINE(OBJ_MAYBE_IEEE)    ;;
+      som)     AC_DEFINE(OBJ_MAYBE_SOM)     ;;
+      vms)     AC_DEFINE(OBJ_MAYBE_VMS)     ;;
+    esac
+    extra_objects="$extra_objects obj-$fmt.o"
+  done
+  obj_format=multi
+fi
+if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
+  te_file=multi
+  extra_objects="$extra_objects $emfiles"
+  DEFAULT_EMULATION=`set . $emulations ; echo $2`
+  AC_DEFINE(USE_EMULATIONS)
+fi
+AC_SUBST(extra_objects)
+AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS)
+AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION")
+
+files="config/tc-${cpu_type}.c config/tc-${cpu_type}.h \
+       config/obj-${obj_format}.h config/obj-${obj_format}.c \
+       config/te-${te_file}.h config/atof-${atof}.c \
+       $extra_files"
+links="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c \
+       $extra_links"
+
+case ${primary_bfd_gas}-${cpu_type}-${obj_format} in
   yes-*-coff)  need_bfd=yes ;;
   no-*-coff)   need_bfd=yes
                AC_DEFINE(MANY_SEGMENTS) ;;
@@ -299,14 +472,11 @@ esac
 AC_SUBST(cpu_type)
 AC_SUBST(obj_format)
 AC_SUBST(atof)
-AC_SUBST(emulation)
+dnl AC_SUBST(emulation)
 
-AC_LINK_FILES(config/tc-${cpu_type}.c  config/tc-${cpu_type}.h \
-       config/obj-${obj_format}.h config/obj-${obj_format}.c \
-       config/te-${emulation}.h config/atof-${atof}.c,
-       targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c)
+AC_LINK_FILES($files, $links)
 
-case "${bfd_gas}" in
+case "${primary_bfd_gas}" in
   yes) AC_DEFINE(BFD_ASSEMBLER)
        need_bfd=yes ;;
 esac
diff --git a/gas/emul-target.h b/gas/emul-target.h
new file mode 100644 (file)
index 0000000..3704050
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef emul_init
+#define emul_init                      common_emul_init
+#endif
+
+#ifndef emul_bfd_name
+#define emul_bfd_name                  default_emul_bfd_name
+#endif
+
+#ifndef emul_local_labels_fb
+#define emul_local_labels_fb           0
+#endif
+
+#ifndef emul_local_labels_dollar
+#define emul_local_labels_dollar       0
+#endif
+
+#ifndef emul_leading_underscore
+#define emul_leading_underscore                2
+#endif
+
+#ifndef emul_strip_underscore
+#define emul_strip_underscore          0
+#endif
+
+#ifndef emul_default_endian
+#define emul_default_endian            2
+#endif
+
+#ifndef emul_fake_label_name
+#define emul_fake_label_name           0
+#endif
+
+struct emulation emul_struct_name = {
+  0,
+  emul_name,
+  emul_init,
+  emul_bfd_name,
+  emul_local_labels_fb, emul_local_labels_dollar,
+  emul_leading_underscore, emul_strip_underscore,
+  emul_default_endian,
+  emul_fake_label_name,
+  emul_format,
+};
diff --git a/gas/emul.h b/gas/emul.h
new file mode 100644 (file)
index 0000000..c3e2469
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef EMUL_DEFS
+#define EMUL_DEFS
+
+struct emulation {
+  void (*match) PARAMS ((const char *));
+  const char *name;
+  void (*init) ();
+  const char *(*bfd_name) ();
+  unsigned char local_labels_fb : 1;
+  unsigned char local_labels_dollar : 1;
+  unsigned char leading_underscore : 2;
+  unsigned char strip_underscore : 1;
+  unsigned char default_endian : 2;
+  const char *fake_label_name;
+  const struct format_ops *format;
+};
+
+COMMON struct emulation *this_emulation;
+
+extern const char *default_emul_bfd_name ();
+extern void common_emul_init ();
+
+#endif