MIPS/GAS: Relax branches to symbols resolved at link time
[deliverable/binutils-gdb.git] / gas / config / obj-ecoff.c
index 767dc588c82968e0fa7a4140f6b645cba78931a9..b994986f6033c031a2178a38355d02da621f0081 100644 (file)
@@ -1,6 +1,5 @@
 /* ECOFF object file format.
 /* ECOFF object file format.
-   Copyright (C) 1993, 94, 95, 96, 97, 98, 99, 2000
-   Free Software Foundation, Inc.
+   Copyright (C) 1993-2016 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    This file was put together by Ian Lance Taylor <ian@cygnus.com>.
 
    Contributed by Cygnus Support.
    This file was put together by Ian Lance Taylor <ian@cygnus.com>.
 
@@ -8,7 +7,7 @@
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
    any later version.
 
    GAS is distributed in the hope that it will be useful,
@@ -18,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
 
    You should have received a copy of the GNU General Public License
    along with GAS; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 #define OBJ_HEADER "obj-ecoff.h"
 #include "as.h"
 
 #define OBJ_HEADER "obj-ecoff.h"
 #include "as.h"
    gas directory.  This file mostly just arranges to call that one at
    the right times.  */
 
    gas directory.  This file mostly just arranges to call that one at
    the right times.  */
 
-static int ecoff_sec_sym_ok_for_reloc PARAMS ((asection *));
-static void obj_ecoff_frob_symbol PARAMS ((symbolS *, int *));
-static void ecoff_pop_insert PARAMS ((void));
-
-/* These are the pseudo-ops we support in this file.  Only those
-   relating to debugging information are supported here.
-
-   The following pseudo-ops from the Kane and Heinrich MIPS book
-   should be defined here, but are currently unsupported: .aent,
-   .bgnb, .endb, .verstamp, .vreg.
-
-   The following pseudo-ops from the Kane and Heinrich MIPS book are
-   MIPS CPU specific, and should be defined by tc-mips.c: .alias,
-   .extern, .galive, .gjaldef, .gjrlive, .livereg, .noalias, .option,
-   .rdata, .sdata, .set.
-
-   The following pseudo-ops from the Kane and Heinrich MIPS book are
-   not MIPS CPU specific, but are also not ECOFF specific.  I have
-   only listed the ones which are not already in read.c.  It's not
-   completely clear where these should be defined, but tc-mips.c is
-   probably the most reasonable place: .asciiz, .asm0, .endr, .err,
-   .half, .lab, .repeat, .struct, .weakext.  */
-
-const pseudo_typeS obj_pseudo_table[] =
-{
-  /* COFF style debugging information. .ln is not used; .loc is used
-     instead.  */
-  { "def",     ecoff_directive_def,    0 },
-  { "dim",     ecoff_directive_dim,    0 },
-  { "endef",   ecoff_directive_endef,  0 },
-  { "file",    ecoff_directive_file,   0 },
-  { "scl",     ecoff_directive_scl,    0 },
-  { "size",    ecoff_directive_size,   0 },
-  { "esize",   ecoff_directive_size,   0 },
-  { "tag",     ecoff_directive_tag,    0 },
-  { "type",    ecoff_directive_type,   0 },
-  { "etype",   ecoff_directive_type,   0 },
-  { "val",     ecoff_directive_val,    0 },
-
-  /* ECOFF specific debugging information.  */
-  { "begin",   ecoff_directive_begin,  0 },
-  { "bend",    ecoff_directive_bend,   0 },
-  { "end",     ecoff_directive_end,    0 },
-  { "ent",     ecoff_directive_ent,    0 },
-  { "fmask",   ecoff_directive_fmask,  0 },
-  { "frame",   ecoff_directive_frame,  0 },
-  { "loc",     ecoff_directive_loc,    0 },
-  { "mask",    ecoff_directive_mask,   0 },
-
-  /* Other ECOFF directives.  */
-  { "extern",  ecoff_directive_extern, 0 },
-
-#ifndef TC_MIPS
-  /* For TC_MIPS, tc-mips.c adds this. */
-  { "weakext", ecoff_directive_weakext, 0 },
-#endif
-
-  /* These are used on Irix.  I don't know how to implement them.  */
-  { "bgnb",    s_ignore,               0 },
-  { "endb",    s_ignore,               0 },
-  { "verstamp",        s_ignore,               0 },
-
-  /* Sentinel.  */
-  { NULL }
-};
-
-/* Swap out the symbols and debugging information for BFD.  */
+/* Set section VMAs and GP values before reloc processing.  */
 
 void
 
 void
-ecoff_frob_file ()
+ecoff_frob_file_before_fix (void)
 {
 {
-  const struct ecoff_debug_swap * const debug_swap
-    = &ecoff_backend (stdoutput)->debug_swap;
   bfd_vma addr;
   asection *sec;
   bfd_vma addr;
   asection *sec;
-  HDRR *hdr;
-  char *buf;
-  char *set;
 
   /* Set the section VMA values.  We force the .sdata and .sbss
      sections to the end to ensure that their VMA addresses are close
 
   /* Set the section VMA values.  We force the .sdata and .sbss
      sections to the end to ensure that their VMA addresses are close
@@ -132,7 +60,8 @@ ecoff_frob_file ()
 
      I don't know if section ordering on the MIPS is important.  */
 
 
      I don't know if section ordering on the MIPS is important.  */
 
-  static const char *const names[] = {
+  static const char *const names[] =
+  {
     /* text segment */
     ".text", ".rdata", ".init", ".fini",
     /* data segment */
     /* text segment */
     ".text", ".rdata", ".init", ".fini",
     /* data segment */
@@ -140,85 +69,40 @@ ecoff_frob_file ()
     /* bss segment */
     ".sbss", ".bss",
   };
     /* bss segment */
     ".sbss", ".bss",
   };
-#define n_names (sizeof (names) / sizeof (names[0]))
+#define n_names ((int) (sizeof (names) / sizeof (names[0])))
+
+  /* Sections that match names, order to be straightened out later.  */
+  asection *secs[n_names];
+  int i;
 
   addr = 0;
 
   addr = 0;
-  {
-    /* Sections that match names, order to be straightened out later.  */
-    asection *secs[n_names];
-    /* Linked list of sections with non-matching names.  Random ordering.  */
-    asection *other_sections = 0;
-    /* Pointer to next section, since we're destroying the original
-       ordering.  */
-    asection *next;
-
-    int i;
-
-    for (i = 0; i < n_names; i++)
-      secs[i] = 0;
-    for (sec = stdoutput->sections; sec != (asection *) NULL; sec = next)
-      {
-       next = sec->next;
-       for (i = 0; i < n_names; i++)
-         if (!strcmp (sec->name, names[i]))
-           {
-             secs[i] = sec;
-             break;
-           }
-       if (i == n_names)
+  for (i = 0; i < n_names; i++)
+    secs[i] = NULL;
+
+  for (sec = stdoutput->sections; sec != NULL; sec = sec->next)
+    {
+      for (i = 0; i < n_names; i++)
+       if (!strcmp (sec->name, names[i]))
          {
          {
-           bfd_set_section_vma (stdoutput, sec, addr);
-           addr += bfd_section_size (stdoutput, sec);
-           sec->next = other_sections;
-           other_sections = sec;
+           secs[i] = sec;
+           bfd_section_list_remove (stdoutput, sec);
+           break;
          }
          }
-      }
-    for (i = 0; i < n_names; i++)
-      if (secs[i])
+      if (i == n_names)
        {
        {
-         sec = secs[i];
          bfd_set_section_vma (stdoutput, sec, addr);
          addr += bfd_section_size (stdoutput, sec);
        }
          bfd_set_section_vma (stdoutput, sec, addr);
          addr += bfd_section_size (stdoutput, sec);
        }
-    for (i = n_names - 1; i >= 0; i--)
-      if (secs[i])
-       {
-         sec = secs[i];
-         sec->next = other_sections;
-         other_sections = sec;
-       }
-    stdoutput->sections = other_sections;
-  }
-
-  /* Build the ECOFF debugging information.  */
-  assert (ecoff_data (stdoutput) != 0);
-  hdr = &ecoff_data (stdoutput)->debug_info.symbolic_header;
-  ecoff_build_debug (hdr, &buf, debug_swap);
-
-  /* Finish up the ecoff_tdata structure.  */
-  set = buf;
-#define SET(ptr, count, type, size) \
-  if (hdr->count == 0) \
-    ecoff_data (stdoutput)->debug_info.ptr = (type) NULL; \
-  else \
-    { \
-      ecoff_data (stdoutput)->debug_info.ptr = (type) set; \
-      set += hdr->count * size; \
     }
     }
-
-  SET (line, cbLine, unsigned char *, sizeof (unsigned char));
-  SET (external_dnr, idnMax, PTR, debug_swap->external_dnr_size);
-  SET (external_pdr, ipdMax, PTR, debug_swap->external_pdr_size);
-  SET (external_sym, isymMax, PTR, debug_swap->external_sym_size);
-  SET (external_opt, ioptMax, PTR, debug_swap->external_opt_size);
-  SET (external_aux, iauxMax, union aux_ext *, sizeof (union aux_ext));
-  SET (ss, issMax, char *, sizeof (char));
-  SET (ssext, issExtMax, char *, sizeof (char));
-  SET (external_rfd, crfd, PTR, debug_swap->external_rfd_size);
-  SET (external_fdr, ifdMax, PTR, debug_swap->external_fdr_size);
-  SET (external_ext, iextMax, PTR, debug_swap->external_ext_size);
-
-#undef SET
+  for (i = 0; i < n_names; i++)
+    if (secs[i])
+      {
+       bfd_set_section_vma (stdoutput, secs[i], addr);
+       addr += bfd_section_size (stdoutput, secs[i]);
+      }
+  for (i = n_names - 1; i >= 0; i--)
+    if (secs[i])
+      bfd_section_list_prepend (stdoutput, secs[i]);
 
   /* Fill in the register masks.  */
   {
 
   /* Fill in the register masks.  */
   {
@@ -248,14 +132,54 @@ ecoff_frob_file ()
   }
 }
 
   }
 }
 
+/* Swap out the symbols and debugging information for BFD.  */
+
+void
+ecoff_frob_file (void)
+{
+  const struct ecoff_debug_swap * const debug_swap
+    = &ecoff_backend (stdoutput)->debug_swap;
+  bfd_vma addr ATTRIBUTE_UNUSED;
+  HDRR *hdr;
+  char *buf;
+  char *set;
+
+  /* Build the ECOFF debugging information.  */
+  gas_assert (ecoff_data (stdoutput) != 0);
+  hdr = &ecoff_data (stdoutput)->debug_info.symbolic_header;
+  ecoff_build_debug (hdr, &buf, debug_swap);
+
+  /* Finish up the ecoff_tdata structure.  */
+  set = buf;
+#define SET(ptr, count, type, size) \
+  if (hdr->count == 0) \
+    ecoff_data (stdoutput)->debug_info.ptr = NULL; \
+  else \
+    { \
+      ecoff_data (stdoutput)->debug_info.ptr = (type) set; \
+      set += hdr->count * size; \
+    }
+
+  SET (line, cbLine, unsigned char *, sizeof (unsigned char));
+  SET (external_dnr, idnMax, void *, debug_swap->external_dnr_size);
+  SET (external_pdr, ipdMax, void *, debug_swap->external_pdr_size);
+  SET (external_sym, isymMax, void *, debug_swap->external_sym_size);
+  SET (external_opt, ioptMax, void *, debug_swap->external_opt_size);
+  SET (external_aux, iauxMax, union aux_ext *, sizeof (union aux_ext));
+  SET (ss, issMax, char *, sizeof (char));
+  SET (ssext, issExtMax, char *, sizeof (char));
+  SET (external_rfd, crfd, void *, debug_swap->external_rfd_size);
+  SET (external_fdr, ifdMax, void *, debug_swap->external_fdr_size);
+  SET (external_ext, iextMax, void *, debug_swap->external_ext_size);
+#undef SET
+}
+
 /* This is called by the ECOFF code to set the external information
    for a symbol.  We just pass it on to BFD, which expects the swapped
    information to be stored in the native field of the symbol.  */
 
 void
 /* This is called by the ECOFF code to set the external information
    for a symbol.  We just pass it on to BFD, which expects the swapped
    information to be stored in the native field of the symbol.  */
 
 void
-obj_ecoff_set_ext (sym, ext)
-     symbolS *sym;
-     EXTR *ext;
+obj_ecoff_set_ext (symbolS *sym, EXTR *ext)
 {
   const struct ecoff_debug_swap * const debug_swap
     = &ecoff_backend (stdoutput)->debug_swap;
 {
   const struct ecoff_debug_swap * const debug_swap
     = &ecoff_backend (stdoutput)->debug_swap;
@@ -264,52 +188,132 @@ obj_ecoff_set_ext (sym, ext)
   know (bfd_asymbol_flavour (symbol_get_bfdsym (sym))
        == bfd_target_ecoff_flavour);
   esym = ecoffsymbol (symbol_get_bfdsym (sym));
   know (bfd_asymbol_flavour (symbol_get_bfdsym (sym))
        == bfd_target_ecoff_flavour);
   esym = ecoffsymbol (symbol_get_bfdsym (sym));
-  esym->local = false;
+  esym->local = FALSE;
   esym->native = xmalloc (debug_swap->external_ext_size);
   (*debug_swap->swap_ext_out) (stdoutput, ext, esym->native);
 }
 
 static int
   esym->native = xmalloc (debug_swap->external_ext_size);
   (*debug_swap->swap_ext_out) (stdoutput, ext, esym->native);
 }
 
 static int
-ecoff_sec_sym_ok_for_reloc (sec)
-     asection *sec;
+ecoff_sec_sym_ok_for_reloc (asection *sec ATTRIBUTE_UNUSED)
 {
   return 1;
 }
 
 static void
 {
   return 1;
 }
 
 static void
-obj_ecoff_frob_symbol (sym, puntp)
-     symbolS *sym;
-     int *puntp;
+obj_ecoff_frob_symbol (symbolS *sym, int *puntp ATTRIBUTE_UNUSED)
 {
   ecoff_frob_symbol (sym);
 }
 
 static void
 {
   ecoff_frob_symbol (sym);
 }
 
 static void
-ecoff_pop_insert ()
+ecoff_pop_insert (void)
 {
   pop_insert (obj_pseudo_table);
 }
 
 {
   pop_insert (obj_pseudo_table);
 }
 
+static int
+ecoff_separate_stab_sections (void)
+{
+  return 0;
+}
+
+/* These are the pseudo-ops we support in this file.  Only those
+   relating to debugging information are supported here.
+
+   The following pseudo-ops from the Kane and Heinrich MIPS book
+   should be defined here, but are currently unsupported: .aent,
+   .bgnb, .endb, .verstamp, .vreg.
+
+   The following pseudo-ops from the Kane and Heinrich MIPS book are
+   MIPS CPU specific, and should be defined by tc-mips.c: .alias,
+   .extern, .galive, .gjaldef, .gjrlive, .livereg, .noalias, .option,
+   .rdata, .sdata, .set.
+
+   The following pseudo-ops from the Kane and Heinrich MIPS book are
+   not MIPS CPU specific, but are also not ECOFF specific.  I have
+   only listed the ones which are not already in read.c.  It's not
+   completely clear where these should be defined, but tc-mips.c is
+   probably the most reasonable place: .asciiz, .asm0, .endr, .err,
+   .half, .lab, .repeat, .struct, .weakext.  */
+
+const pseudo_typeS obj_pseudo_table[] =
+{
+  /* COFF style debugging information. .ln is not used; .loc is used
+     instead.  */
+  { "def",     ecoff_directive_def,    0 },
+  { "dim",     ecoff_directive_dim,    0 },
+  { "endef",   ecoff_directive_endef,  0 },
+  { "file",    ecoff_directive_file,   0 },
+  { "scl",     ecoff_directive_scl,    0 },
+  { "size",    ecoff_directive_size,   0 },
+  { "esize",   ecoff_directive_size,   0 },
+  { "tag",     ecoff_directive_tag,    0 },
+  { "type",    ecoff_directive_type,   0 },
+  { "etype",   ecoff_directive_type,   0 },
+  { "val",     ecoff_directive_val,    0 },
+
+  /* ECOFF specific debugging information.  */
+  { "begin",   ecoff_directive_begin,  0 },
+  { "bend",    ecoff_directive_bend,   0 },
+  { "end",     ecoff_directive_end,    0 },
+  { "ent",     ecoff_directive_ent,    0 },
+  { "fmask",   ecoff_directive_fmask,  0 },
+  { "frame",   ecoff_directive_frame,  0 },
+  { "loc",     ecoff_directive_loc,    0 },
+  { "mask",    ecoff_directive_mask,   0 },
+
+  /* Other ECOFF directives.  */
+  { "extern",  ecoff_directive_extern, 0 },
+
+#ifndef TC_MIPS
+  /* For TC_MIPS, tc-mips.c adds this.  */
+  { "weakext", ecoff_directive_weakext, 0 },
+#endif
+
+  /* These are used on Irix.  I don't know how to implement them.  */
+  { "bgnb",    s_ignore,               0 },
+  { "endb",    s_ignore,               0 },
+  { "verstamp",        s_ignore,               0 },
+
+  /* Sentinel.  */
+  { NULL,      s_ignore,               0 }
+};
+
 const struct format_ops ecoff_format_ops =
 {
   bfd_target_ecoff_flavour,
 const struct format_ops ecoff_format_ops =
 {
   bfd_target_ecoff_flavour,
-  0,   /* dfl_leading_underscore */
-  1,   /* emit_section_symbols */
+  0,   /* dfl_leading_underscore.  */
+
+  /* FIXME: A comment why emit_section_symbols is different here (1) from
+     the single-format definition (0) would be in order.  */
+  1,   /* emit_section_symbols.  */
+  0,   /* begin.  */
+  ecoff_new_file,
   obj_ecoff_frob_symbol,
   ecoff_frob_file,
   obj_ecoff_frob_symbol,
   ecoff_frob_file,
-  0,   /* frob_file_after_relocs */
-  0,   /* s_get_size */
-  0,   /* s_set_size */
-  0,   /* s_get_align */
-  0,   /* s_set_align */
-  0,   /* s_get_other */
-  0,   /* s_get_desc */
-  0,   /* copy_symbol_attributes */
+  0,   /* frob_file_before_adjust.  */
+  ecoff_frob_file_before_fix,
+  0,   /* frob_file_after_relocs.  */
+  0,   /* s_get_size.  */
+  0,   /* s_set_size.  */
+  0,   /* s_get_align.  */
+  0,   /* s_set_align.  */
+  0,   /* s_get_other.  */
+  0,   /* s_set_other.  */
+  0,   /* s_get_desc.  */
+  0,   /* s_set_desc.  */
+  0,   /* s_get_type.  */
+  0,   /* s_set_type.  */
+  0,   /* copy_symbol_attributes.  */
   ecoff_generate_asm_lineno,
   ecoff_stab,
   ecoff_generate_asm_lineno,
   ecoff_stab,
+  ecoff_separate_stab_sections,
+  0,   /* init_stab_section.  */
   ecoff_sec_sym_ok_for_reloc,
   ecoff_pop_insert,
   ecoff_set_ext,
   ecoff_read_begin_hook,
   ecoff_symbol_new_hook,
   ecoff_sec_sym_ok_for_reloc,
   ecoff_pop_insert,
   ecoff_set_ext,
   ecoff_read_begin_hook,
   ecoff_symbol_new_hook,
+  ecoff_symbol_clone_hook,
+  0    /* adjust_symtab.  */
 };
 };
This page took 0.027384 seconds and 4 git commands to generate.