Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Typedefs | Functions
libecoff.h File Reference
#include "bfdlink.h"
#include "coff/ecoff.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ecoff_backend_data
struct  ecoff_tdata
struct  ecoff_symbol_struct
struct  ecoff_section_tdata
struct  ecoff_link_hash_entry

Defines

#define ecoff_backend(abfd)   ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
#define ecoff_data(abfd)   ((abfd)->tdata.ecoff_obj_data)
#define ecoffsymbol(asymbol)   ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
#define ecoff_get_sym_index(symbol)   ((symbol)->udata.i)
#define ecoff_set_sym_index(symbol, idx)   ((symbol)->udata.i = (idx))
#define ecoff_section_data(abfd, sec)   ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
#define _bfd_ecoff_close_and_cleanup   _bfd_generic_close_and_cleanup
#define _bfd_ecoff_bfd_free_cached_info   _bfd_generic_bfd_free_cached_info
#define _bfd_ecoff_bfd_link_split_section   _bfd_generic_link_split_section
#define _bfd_ecoff_bfd_copy_private_section_data   _bfd_generic_bfd_copy_private_section_data
#define _bfd_ecoff_bfd_copy_private_symbol_data   _bfd_generic_bfd_copy_private_symbol_data
#define _bfd_ecoff_bfd_copy_private_header_data   _bfd_generic_bfd_copy_private_header_data
#define _bfd_ecoff_bfd_print_private_bfd_data   _bfd_generic_bfd_print_private_bfd_data
#define _bfd_ecoff_bfd_merge_private_bfd_data   _bfd_generic_bfd_merge_private_bfd_data
#define _bfd_ecoff_bfd_set_private_flags   _bfd_generic_bfd_set_private_flags
#define _bfd_ecoff_slurp_extended_name_table   _bfd_slurp_extended_name_table
#define _bfd_ecoff_construct_extended_name_table   _bfd_archive_bsd_construct_extended_name_table
#define _bfd_ecoff_truncate_arname   bfd_dont_truncate_arname
#define _bfd_ecoff_read_ar_hdr   _bfd_generic_read_ar_hdr
#define _bfd_ecoff_openr_next_archived_file   bfd_generic_openr_next_archived_file
#define _bfd_ecoff_get_elt_at_index   _bfd_generic_get_elt_at_index
#define _bfd_ecoff_generic_stat_arch_elt   bfd_generic_stat_arch_elt
#define _bfd_ecoff_update_armap_timestamp   bfd_true
#define _bfd_ecoff_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
#define _bfd_ecoff_get_lineno   _bfd_nosymbols_get_lineno
#define _bfd_ecoff_bfd_make_debug_symbol   _bfd_nosymbols_bfd_make_debug_symbol
#define _bfd_ecoff_read_minisymbols   _bfd_generic_read_minisymbols
#define _bfd_ecoff_minisymbol_to_symbol   _bfd_generic_minisymbol_to_symbol
#define _bfd_ecoff_find_inliner_info   _bfd_nosymbols_find_inliner_info
#define _bfd_ecoff_get_reloc_upper_bound   coff_get_reloc_upper_bound
#define _bfd_ecoff_bfd_link_hash_table_free   _bfd_generic_link_hash_table_free
#define _bfd_ecoff_bfd_link_just_syms   _bfd_generic_link_just_syms
#define _bfd_ecoff_set_alignment_hook   ((void (*) (bfd *, asection *, void *)) bfd_void)

Typedefs

typedef struct ecoff_tdata ecoff_data_type
typedef struct ecoff_symbol_struct ecoff_symbol_type

Functions

bfd_boolean _bfd_ecoff_mkobject (bfd *)
bfd_boolean _bfd_ecoff_slurp_symbolic_info (bfd *, asection *, struct ecoff_debug_info *)
bfd_boolean _bfd_ecoff_write_object_contents (bfd *)
const bfd_target_bfd_ecoff_archive_p (bfd *)
bfd_boolean _bfd_ecoff_new_section_hook (bfd *, asection *)
bfd_boolean _bfd_ecoff_get_section_contents (bfd *, asection *, void *location, file_ptr, bfd_size_type)
bfd_boolean _bfd_ecoff_bfd_copy_private_bfd_data (bfd *, bfd *)
bfd_boolean _bfd_ecoff_slurp_armap (bfd *)
bfd_boolean _bfd_ecoff_write_armap (bfd *, unsigned int, struct orl *, unsigned int, int)
long _bfd_ecoff_get_symtab_upper_bound (bfd *)
long _bfd_ecoff_canonicalize_symtab (bfd *, asymbol **)
asymbol_bfd_ecoff_make_empty_symbol (bfd *)
void _bfd_ecoff_print_symbol (bfd *, void *, asymbol *, bfd_print_symbol_type)
void _bfd_ecoff_get_symbol_info (bfd *, asymbol *, symbol_info *)
bfd_boolean _bfd_ecoff_bfd_is_local_label_name (bfd *, const char *)
bfd_boolean _bfd_ecoff_find_nearest_line (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, unsigned int *)
long _bfd_ecoff_canonicalize_reloc (bfd *, asection *, arelent **, asymbol **symbols)
bfd_boolean _bfd_ecoff_set_arch_mach (bfd *, enum bfd_architecture, unsigned long)
bfd_boolean _bfd_ecoff_set_section_contents (bfd *, asection *, const void *location, file_ptr, bfd_size_type)
int _bfd_ecoff_sizeof_headers (bfd *, struct bfd_link_info *)
struct bfd_link_hash_table_bfd_ecoff_bfd_link_hash_table_create (bfd *)
bfd_boolean _bfd_ecoff_bfd_link_add_symbols (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_ecoff_bfd_final_link (bfd *, struct bfd_link_info *)
void * _bfd_ecoff_mkobject_hook (bfd *, void *, void *)
bfd_boolean _bfd_ecoff_set_arch_mach_hook (bfd *, void *)
bfd_boolean _bfd_ecoff_styp_to_sec_flags (bfd *, void *, const char *, asection *, flagword *)
bfd_boolean _bfd_ecoff_slurp_symbol_table (bfd *)
void _bfd_ecoff_swap_tir_in (int, const struct tir_ext *, TIR *)
void _bfd_ecoff_swap_tir_out (int, const TIR *, struct tir_ext *)
void _bfd_ecoff_swap_rndx_in (int, const struct rndx_ext *, RNDXR *)
void _bfd_ecoff_swap_rndx_out (int, const RNDXR *, struct rndx_ext *)

Class Documentation

struct ecoff_tdata

Definition at line 82 of file libecoff.h.

Collaboration diagram for ecoff_tdata:
Class Members
struct ecoff_symbol_struct * canonical_symbols
unsigned long cprmask
struct ecoff_find_line * find_line_info
unsigned long fprmask
bfd_vma gp
unsigned int gp_size
unsigned long gprmask
bfd_boolean issued_multiple_gp_warning
bfd_boolean linker
void * raw_syments
bfd_boolean rdata_in_text
file_ptr reloc_filepos
file_ptr sym_filepos
struct ecoff_link_hash_entry ** sym_hashes
asection ** symndx_to_section
unsigned long text_end
unsigned long text_start
struct ecoff_symbol_struct

Definition at line 150 of file libecoff.h.

Collaboration diagram for ecoff_symbol_struct:
Class Members
FDR * fdr
bfd_boolean local
void * native
asymbol symbol
struct ecoff_section_tdata

Definition at line 182 of file libecoff.h.

Class Members
bfd_vma gp
struct ecoff_link_hash_entry

Definition at line 199 of file libecoff.h.

Collaboration diagram for ecoff_link_hash_entry:
Class Members
bfd * abfd
EXTR esym
long indx
char small
char written
struct ecoff_link_hash_table

Definition at line 216 of file libecoff.h.


Define Documentation

Definition at line 250 of file libecoff.h.

Definition at line 244 of file libecoff.h.

Definition at line 247 of file libecoff.h.

Definition at line 234 of file libecoff.h.

Definition at line 273 of file libecoff.h.

Definition at line 309 of file libecoff.h.

Definition at line 312 of file libecoff.h.

Definition at line 240 of file libecoff.h.

Definition at line 289 of file libecoff.h.

Definition at line 256 of file libecoff.h.

Definition at line 253 of file libecoff.h.

Definition at line 259 of file libecoff.h.

Definition at line 233 of file libecoff.h.

Definition at line 262 of file libecoff.h.

Definition at line 292 of file libecoff.h.

Definition at line 271 of file libecoff.h.

Definition at line 270 of file libecoff.h.

Definition at line 285 of file libecoff.h.

Definition at line 294 of file libecoff.h.

Definition at line 291 of file libecoff.h.

Definition at line 268 of file libecoff.h.

Definition at line 267 of file libecoff.h.

Definition at line 290 of file libecoff.h.

#define _bfd_ecoff_set_alignment_hook   ((void (*) (bfd *, asection *, void *)) bfd_void)

Definition at line 319 of file libecoff.h.

Definition at line 261 of file libecoff.h.

Definition at line 264 of file libecoff.h.

Definition at line 272 of file libecoff.h.

#define ecoff_backend (   abfd)    ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)

Definition at line 33 of file libecoff.h.

#define ecoff_data (   abfd)    ((abfd)->tdata.ecoff_obj_data)

Definition at line 80 of file libecoff.h.

#define ecoff_get_sym_index (   symbol)    ((symbol)->udata.i)

Definition at line 174 of file libecoff.h.

#define ecoff_section_data (   abfd,
  sec 
)    ((struct ecoff_section_tdata *) (sec)->used_by_bfd)

Definition at line 194 of file libecoff.h.

#define ecoff_set_sym_index (   symbol,
  idx 
)    ((symbol)->udata.i = (idx))

Definition at line 175 of file libecoff.h.

#define ecoffsymbol (   asymbol)    ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))

Definition at line 169 of file libecoff.h.


Typedef Documentation


Function Documentation

Definition at line 3161 of file ecoff.c.

{
  struct artdata *tdata_hold;
  char armag[SARMAG + 1];
  bfd_size_type amt;

  if (bfd_bread ((void *) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
    {
      if (bfd_get_error () != bfd_error_system_call)
       bfd_set_error (bfd_error_wrong_format);
      return NULL;
    }

  if (! strneq (armag, ARMAG, SARMAG))
    {
      bfd_set_error (bfd_error_wrong_format);
      return NULL;
    }

  tdata_hold = bfd_ardata (abfd);

  amt = sizeof (struct artdata);
  bfd_ardata (abfd) = bfd_zalloc (abfd, amt);
  if (bfd_ardata (abfd) == NULL)
    {
      bfd_ardata (abfd) = tdata_hold;
      return NULL;
    }

  bfd_ardata (abfd)->first_file_filepos = SARMAG;
  /* Already cleared by bfd_zalloc above.
     bfd_ardata (abfd)->cache = NULL;
     bfd_ardata (abfd)->archive_head = NULL;
     bfd_ardata (abfd)->symdefs = NULL;
     bfd_ardata (abfd)->extended_names = NULL;
     bfd_ardata (abfd)->extended_names_size = 0;
     bfd_ardata (abfd)->tdata = NULL;  */

  if (! _bfd_ecoff_slurp_armap (abfd)
      || ! _bfd_ecoff_slurp_extended_name_table (abfd))
    {
      bfd_release (abfd, bfd_ardata (abfd));
      bfd_ardata (abfd) = tdata_hold;
      return NULL;
    }

  if (bfd_has_map (abfd))
    {
      bfd *first;

      /* This archive has a map, so we may presume that the contents
        are object files.  Make sure that if the first file in the
        archive can be recognized as an object file, it is for this
        target.  If not, assume that this is the wrong format.  If
        the first file is not an object file, somebody is doing
        something weird, and we permit it so that ar -t will work.  */

      first = bfd_openr_next_archived_file (abfd, NULL);
      if (first != NULL)
       {
         first->target_defaulted = FALSE;
         if (bfd_check_format (first, bfd_object)
             && first->xvec != abfd->xvec)
           {
             /* We ought to close `first' here, but we can't, because
               we have no way to remove it from the archive cache.
               It's almost impossible to figure out when we can
               release bfd_ardata.  FIXME.  */
             bfd_set_error (bfd_error_wrong_object_format);
             bfd_ardata (abfd) = tdata_hold;
             return NULL;
           }
         /* And we ought to close `first' here too.  */
       }
    }

  return abfd->xvec;
}

Here is the call graph for this function:

Definition at line 1746 of file ecoff.c.

{
  struct ecoff_debug_info *iinfo = &ecoff_data (ibfd)->debug_info;
  struct ecoff_debug_info *oinfo = &ecoff_data (obfd)->debug_info;
  int i;
  asymbol **sym_ptr_ptr;
  size_t c;
  bfd_boolean local;

  /* We only want to copy information over if both BFD's use ECOFF
     format.  */
  if (bfd_get_flavour (ibfd) != bfd_target_ecoff_flavour
      || bfd_get_flavour (obfd) != bfd_target_ecoff_flavour)
    return TRUE;

  /* Copy the GP value and the register masks.  */
  ecoff_data (obfd)->gp = ecoff_data (ibfd)->gp;
  ecoff_data (obfd)->gprmask = ecoff_data (ibfd)->gprmask;
  ecoff_data (obfd)->fprmask = ecoff_data (ibfd)->fprmask;
  for (i = 0; i < 3; i++)
    ecoff_data (obfd)->cprmask[i] = ecoff_data (ibfd)->cprmask[i];

  /* Copy the version stamp.  */
  oinfo->symbolic_header.vstamp = iinfo->symbolic_header.vstamp;

  /* If there are no symbols, don't copy any debugging information.  */
  c = bfd_get_symcount (obfd);
  sym_ptr_ptr = bfd_get_outsymbols (obfd);
  if (c == 0 || sym_ptr_ptr == NULL)
    return TRUE;

  /* See if there are any local symbols.  */
  local = FALSE;
  for (; c > 0; c--, sym_ptr_ptr++)
    {
      if (ecoffsymbol (*sym_ptr_ptr)->local)
       {
         local = TRUE;
         break;
       }
    }

  if (local)
    {
      /* There are some local symbols.  We just bring over all the
        debugging information.  FIXME: This is not quite the right
        thing to do.  If the user has asked us to discard all
        debugging information, then we are probably going to wind up
        keeping it because there will probably be some local symbol
        which objcopy did not discard.  We should actually break
        apart the debugging information and only keep that which
        applies to the symbols we want to keep.  */
      oinfo->symbolic_header.ilineMax = iinfo->symbolic_header.ilineMax;
      oinfo->symbolic_header.cbLine = iinfo->symbolic_header.cbLine;
      oinfo->line = iinfo->line;

      oinfo->symbolic_header.idnMax = iinfo->symbolic_header.idnMax;
      oinfo->external_dnr = iinfo->external_dnr;

      oinfo->symbolic_header.ipdMax = iinfo->symbolic_header.ipdMax;
      oinfo->external_pdr = iinfo->external_pdr;

      oinfo->symbolic_header.isymMax = iinfo->symbolic_header.isymMax;
      oinfo->external_sym = iinfo->external_sym;

      oinfo->symbolic_header.ioptMax = iinfo->symbolic_header.ioptMax;
      oinfo->external_opt = iinfo->external_opt;

      oinfo->symbolic_header.iauxMax = iinfo->symbolic_header.iauxMax;
      oinfo->external_aux = iinfo->external_aux;

      oinfo->symbolic_header.issMax = iinfo->symbolic_header.issMax;
      oinfo->ss = iinfo->ss;

      oinfo->symbolic_header.ifdMax = iinfo->symbolic_header.ifdMax;
      oinfo->external_fdr = iinfo->external_fdr;

      oinfo->symbolic_header.crfd = iinfo->symbolic_header.crfd;
      oinfo->external_rfd = iinfo->external_rfd;
    }
  else
    {
      /* We are discarding all the local symbol information.  Look
        through the external symbols and remove all references to FDR
        or aux information.  */
      c = bfd_get_symcount (obfd);
      sym_ptr_ptr = bfd_get_outsymbols (obfd);
      for (; c > 0; c--, sym_ptr_ptr++)
       {
         EXTR esym;

         (*(ecoff_backend (obfd)->debug_swap.swap_ext_in))
           (obfd, ecoffsymbol (*sym_ptr_ptr)->native, &esym);
         esym.ifd = ifdNil;
         esym.asym.index = indexNil;
         (*(ecoff_backend (obfd)->debug_swap.swap_ext_out))
           (obfd, &esym, ecoffsymbol (*sym_ptr_ptr)->native);
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Definition at line 4440 of file ecoff.c.

{
  const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
  struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
  HDRR *symhdr;
  void * handle;
  bfd *input_bfd;
  asection *o;
  struct bfd_link_order *p;
  struct extsym_info einfo;

  /* We accumulate the debugging information counts in the symbolic
     header.  */
  symhdr = &debug->symbolic_header;
  symhdr->vstamp = 0;
  symhdr->ilineMax = 0;
  symhdr->cbLine = 0;
  symhdr->idnMax = 0;
  symhdr->ipdMax = 0;
  symhdr->isymMax = 0;
  symhdr->ioptMax = 0;
  symhdr->iauxMax = 0;
  symhdr->issMax = 0;
  symhdr->issExtMax = 0;
  symhdr->ifdMax = 0;
  symhdr->crfd = 0;
  symhdr->iextMax = 0;

  /* We accumulate the debugging information itself in the debug_info
     structure.  */
  debug->line = NULL;
  debug->external_dnr = NULL;
  debug->external_pdr = NULL;
  debug->external_sym = NULL;
  debug->external_opt = NULL;
  debug->external_aux = NULL;
  debug->ss = NULL;
  debug->ssext = debug->ssext_end = NULL;
  debug->external_fdr = NULL;
  debug->external_rfd = NULL;
  debug->external_ext = debug->external_ext_end = NULL;

  handle = bfd_ecoff_debug_init (abfd, debug, &backend->debug_swap, info);
  if (handle == NULL)
    return FALSE;

  /* Accumulate the debugging symbols from each input BFD.  */
  for (input_bfd = info->input_bfds;
       input_bfd != NULL;
       input_bfd = input_bfd->link_next)
    {
      bfd_boolean ret;

      if (bfd_get_flavour (input_bfd) == bfd_target_ecoff_flavour)
       {
         /* Arbitrarily set the symbolic header vstamp to the vstamp
            of the first object file in the link.  */
         if (symhdr->vstamp == 0)
           symhdr->vstamp
             = ecoff_data (input_bfd)->debug_info.symbolic_header.vstamp;
         ret = ecoff_final_link_debug_accumulate (abfd, input_bfd, info,
                                             handle);
       }
      else
       ret = bfd_ecoff_debug_accumulate_other (handle, abfd,
                                          debug, &backend->debug_swap,
                                          input_bfd, info);
      if (! ret)
       return FALSE;

      /* Combine the register masks.  */
      ecoff_data (abfd)->gprmask |= ecoff_data (input_bfd)->gprmask;
      ecoff_data (abfd)->fprmask |= ecoff_data (input_bfd)->fprmask;
      ecoff_data (abfd)->cprmask[0] |= ecoff_data (input_bfd)->cprmask[0];
      ecoff_data (abfd)->cprmask[1] |= ecoff_data (input_bfd)->cprmask[1];
      ecoff_data (abfd)->cprmask[2] |= ecoff_data (input_bfd)->cprmask[2];
      ecoff_data (abfd)->cprmask[3] |= ecoff_data (input_bfd)->cprmask[3];
    }

  /* Write out the external symbols.  */
  einfo.abfd = abfd;
  einfo.info = info;
  ecoff_link_hash_traverse (ecoff_hash_table (info),
                         ecoff_link_write_external,
                         (void *) &einfo);

  if (info->relocatable)
    {
      /* We need to make a pass over the link_orders to count up the
        number of relocations we will need to output, so that we know
        how much space they will take up.  */
      for (o = abfd->sections; o != NULL; o = o->next)
       {
         o->reloc_count = 0;
         for (p = o->map_head.link_order;
              p != NULL;
              p = p->next)
           if (p->type == bfd_indirect_link_order)
             o->reloc_count += p->u.indirect.section->reloc_count;
           else if (p->type == bfd_section_reloc_link_order
                   || p->type == bfd_symbol_reloc_link_order)
             ++o->reloc_count;
       }
    }

  /* Compute the reloc and symbol file positions.  */
  ecoff_compute_reloc_file_positions (abfd);

  /* Write out the debugging information.  */
  if (! bfd_ecoff_write_accumulated_debug (handle, abfd, debug,
                                      &backend->debug_swap, info,
                                      ecoff_data (abfd)->sym_filepos))
    return FALSE;

  bfd_ecoff_debug_free (handle, abfd, debug, &backend->debug_swap, info);

  if (info->relocatable)
    {
      /* Now reset the reloc_count field of the sections in the output
        BFD to 0, so that we can use them to keep track of how many
        relocs we have output thus far.  */
      for (o = abfd->sections; o != NULL; o = o->next)
       o->reloc_count = 0;
    }

  /* Get a value for the GP register.  */
  if (ecoff_data (abfd)->gp == 0)
    {
      struct bfd_link_hash_entry *h;

      h = bfd_link_hash_lookup (info->hash, "_gp", FALSE, FALSE, TRUE);
      if (h != NULL
         && h->type == bfd_link_hash_defined)
       ecoff_data (abfd)->gp = (h->u.def.value
                             + h->u.def.section->output_section->vma
                             + h->u.def.section->output_offset);
      else if (info->relocatable)
       {
         bfd_vma lo;

         /* Make up a value.  */
         lo = (bfd_vma) -1;
         for (o = abfd->sections; o != NULL; o = o->next)
           {
             if (o->vma < lo
                && (streq (o->name, _SBSS)
                    || streq (o->name, _SDATA)
                    || streq (o->name, _LIT4)
                    || streq (o->name, _LIT8)
                    || streq (o->name, _LITA)))
              lo = o->vma;
           }
         ecoff_data (abfd)->gp = lo + 0x8000;
       }
      else
       {
         /* If the relocate_section function needs to do a reloc
            involving the GP value, it should make a reloc_dangerous
            callback to warn that GP is not defined.  */
       }
    }

  for (o = abfd->sections; o != NULL; o = o->next)
    {
      for (p = o->map_head.link_order;
          p != NULL;
          p = p->next)
       {
         if (p->type == bfd_indirect_link_order
             && (bfd_get_flavour (p->u.indirect.section->owner)
                == bfd_target_ecoff_flavour))
           {
             if (! ecoff_indirect_link_order (abfd, info, o, p))
              return FALSE;
           }
         else if (p->type == bfd_section_reloc_link_order
                 || p->type == bfd_symbol_reloc_link_order)
           {
             if (! ecoff_reloc_link_order (abfd, info, o, p))
              return FALSE;
           }
         else
           {
             if (! _bfd_default_link_order (abfd, info, o, p))
              return FALSE;
           }
       }
    }

  bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;

  ecoff_data (abfd)->linker = TRUE;

  return TRUE;
}

Here is the call graph for this function:

Definition at line 3865 of file ecoff.c.

Here is the call graph for this function:

Definition at line 3280 of file ecoff.c.

{
  struct ecoff_link_hash_table *ret;
  bfd_size_type amt = sizeof (struct ecoff_link_hash_table);

  ret = bfd_malloc (amt);
  if (ret == NULL)
    return NULL;
  if (!_bfd_link_hash_table_init (&ret->root, abfd,
                              ecoff_link_hash_newfunc,
                              sizeof (struct ecoff_link_hash_entry)))
    {
      free (ret);
      return NULL;
    }
  return &ret->root;
}

Here is the call graph for this function:

long _bfd_ecoff_canonicalize_reloc ( bfd ,
asection ,
arelent **  ,
asymbol **  symbols 
)

Definition at line 1657 of file ecoff.c.

{
  unsigned int count;

  if (section->flags & SEC_CONSTRUCTOR)
    {
      arelent_chain *chain;

      /* This section has relocs made up by us, not the file, so take
        them out of their chain and place them into the data area
        provided.  */
      for (count = 0, chain = section->constructor_chain;
          count < section->reloc_count;
          count++, chain = chain->next)
       *relptr++ = &chain->relent;
    }
  else
    {
      arelent *tblptr;

      if (! ecoff_slurp_reloc_table (abfd, section, symbols))
       return -1;

      tblptr = section->relocation;

      for (count = 0; count < section->reloc_count; count++)
       *relptr++ = tblptr++;
    }

  *relptr = NULL;

  return section->reloc_count;
}

Here is the call graph for this function:

Definition at line 957 of file ecoff.c.

{
  unsigned int counter = 0;
  ecoff_symbol_type *symbase;
  ecoff_symbol_type **location = (ecoff_symbol_type **) alocation;

  if (! _bfd_ecoff_slurp_symbol_table (abfd))
    return -1;
  if (bfd_get_symcount (abfd) == 0)
    return 0;

  symbase = ecoff_data (abfd)->canonical_symbols;
  while (counter < bfd_get_symcount (abfd))
    {
      *(location++) = symbase++;
      counter++;
    }
  *location++ = NULL;
  return bfd_get_symcount (abfd);
}

Here is the call graph for this function:

bfd_boolean _bfd_ecoff_find_nearest_line ( bfd ,
asection ,
asymbol **  ,
bfd_vma  ,
const char **  ,
const char **  ,
unsigned int  
)
bfd_boolean _bfd_ecoff_get_section_contents ( bfd ,
asection ,
void *  location,
file_ptr  ,
bfd_size_type   
)

Definition at line 1887 of file ecoff.c.

{
  return _bfd_generic_get_section_contents (abfd, section, location,
                                       offset, count);
}

Here is the call graph for this function:

void _bfd_ecoff_get_symbol_info ( bfd ,
asymbol ,
symbol_info  
)

Definition at line 942 of file ecoff.c.

{
  if (! _bfd_ecoff_slurp_symbolic_info (abfd, NULL,
                                   &ecoff_data (abfd)->debug_info))
    return -1;

  if (bfd_get_symcount (abfd) == 0)
    return 0;

  return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *));
}

Here is the call graph for this function:

Definition at line 633 of file ecoff.c.

{
  ecoff_symbol_type *new;
  bfd_size_type amt = sizeof (ecoff_symbol_type);

  new = bfd_zalloc (abfd, amt);
  if (new == NULL)
    return NULL;
  new->symbol.section = NULL;
  new->fdr = NULL;
  new->local = FALSE;
  new->native = NULL;
  new->symbol.the_bfd = abfd;
  return &new->symbol;
}

Here is the call graph for this function:

Definition at line 86 of file ecoff.c.

{
  bfd_size_type amt = sizeof (ecoff_data_type);

  abfd->tdata.ecoff_obj_data = bfd_zalloc (abfd, amt);
  if (abfd->tdata.ecoff_obj_data == NULL)
    return FALSE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* _bfd_ecoff_mkobject_hook ( bfd ,
void *  ,
void *   
)

Definition at line 101 of file ecoff.c.

{
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
  struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr;
  ecoff_data_type *ecoff;

  if (! _bfd_ecoff_mkobject (abfd))
    return NULL;

  ecoff = ecoff_data (abfd);
  ecoff->gp_size = 8;
  ecoff->sym_filepos = internal_f->f_symptr;

  if (internal_a != NULL)
    {
      int i;

      ecoff->text_start = internal_a->text_start;
      ecoff->text_end = internal_a->text_start + internal_a->tsize;
      ecoff->gp = internal_a->gp_value;
      ecoff->gprmask = internal_a->gprmask;
      for (i = 0; i < 4; i++)
       ecoff->cprmask[i] = internal_a->cprmask[i];
      ecoff->fprmask = internal_a->fprmask;
      if (internal_a->magic == ECOFF_AOUT_ZMAGIC)
       abfd->flags |= D_PAGED;
      else
       abfd->flags &=~ D_PAGED;
    }

  /* It turns out that no special action is required by the MIPS or
     Alpha ECOFF backends.  They have different information in the
     a.out header, but we just copy it all (e.g., gprmask, cprmask and
     fprmask) and let the swapping routines ensure that only relevant
     information is written out.  */

  return (void *) ecoff;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 143 of file ecoff.c.

{
  unsigned int i;
  static struct
  {
    const char * name;
    flagword flags;
  }
  section_flags [] =
  {
    { _TEXT,   SEC_ALLOC | SEC_CODE | SEC_LOAD },
    { _INIT,   SEC_ALLOC | SEC_CODE | SEC_LOAD },
    { _FINI,   SEC_ALLOC | SEC_CODE | SEC_LOAD },
    { _DATA,   SEC_ALLOC | SEC_DATA | SEC_LOAD },
    { _SDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD },
    { _RDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
    { _LIT8,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
    { _LIT4,   SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
    { _RCONST, SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
    { _PDATA,  SEC_ALLOC | SEC_DATA | SEC_LOAD | SEC_READONLY},
    { _BSS,    SEC_ALLOC},
    { _SBSS,   SEC_ALLOC},
    /* An Irix 4 shared libary.  */
    { _LIB,    SEC_COFF_SHARED_LIBRARY}
  };

  section->alignment_power = 4;

  for (i = 0; i < ARRAY_SIZE (section_flags); i++)
    if (streq (section->name, section_flags[i].name))
      {
       section->flags |= section_flags[i].flags;
       break;
      }


  /* Probably any other section name is SEC_NEVER_LOAD, but I'm
     uncertain about .init on some systems and I don't know how shared
     libraries work.  */

  return _bfd_generic_new_section_hook (abfd, section);
}

Here is the call graph for this function:

void _bfd_ecoff_print_symbol ( bfd ,
void *  ,
asymbol ,
bfd_print_symbol_type   
)

Definition at line 1361 of file ecoff.c.

{
  const struct ecoff_debug_swap * const debug_swap
    = &ecoff_backend (abfd)->debug_swap;
  FILE *file = (FILE *)filep;

  switch (how)
    {
    case bfd_print_symbol_name:
      fprintf (file, "%s", symbol->name);
      break;
    case bfd_print_symbol_more:
      if (ecoffsymbol (symbol)->local)
       {
         SYMR ecoff_sym;

         (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
                                  &ecoff_sym);
         fprintf (file, "ecoff local ");
         fprintf_vma (file, (bfd_vma) ecoff_sym.value);
         fprintf (file, " %x %x", (unsigned) ecoff_sym.st,
                 (unsigned) ecoff_sym.sc);
       }
      else
       {
         EXTR ecoff_ext;

         (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
                                  &ecoff_ext);
         fprintf (file, "ecoff extern ");
         fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
         fprintf (file, " %x %x", (unsigned) ecoff_ext.asym.st,
                 (unsigned) ecoff_ext.asym.sc);
       }
      break;
    case bfd_print_symbol_all:
      /* Print out the symbols in a reasonable way.  */
      {
       char type;
       int pos;
       EXTR ecoff_ext;
       char jmptbl;
       char cobol_main;
       char weakext;

       if (ecoffsymbol (symbol)->local)
         {
           (*debug_swap->swap_sym_in) (abfd, ecoffsymbol (symbol)->native,
                                   &ecoff_ext.asym);
           type = 'l';
           pos = ((((char *) ecoffsymbol (symbol)->native
                   - (char *) ecoff_data (abfd)->debug_info.external_sym)
                  / debug_swap->external_sym_size)
                 + ecoff_data (abfd)->debug_info.symbolic_header.iextMax);
           jmptbl = ' ';
           cobol_main = ' ';
           weakext = ' ';
         }
       else
         {
           (*debug_swap->swap_ext_in) (abfd, ecoffsymbol (symbol)->native,
                                   &ecoff_ext);
           type = 'e';
           pos = (((char *) ecoffsymbol (symbol)->native
                  - (char *) ecoff_data (abfd)->debug_info.external_ext)
                 / debug_swap->external_ext_size);
           jmptbl = ecoff_ext.jmptbl ? 'j' : ' ';
           cobol_main = ecoff_ext.cobol_main ? 'c' : ' ';
           weakext = ecoff_ext.weakext ? 'w' : ' ';
         }

       fprintf (file, "[%3d] %c ",
               pos, type);
       fprintf_vma (file, (bfd_vma) ecoff_ext.asym.value);
       fprintf (file, " st %x sc %x indx %x %c%c%c %s",
               (unsigned) ecoff_ext.asym.st,
               (unsigned) ecoff_ext.asym.sc,
               (unsigned) ecoff_ext.asym.index,
               jmptbl, cobol_main, weakext,
               symbol->name);

       if (ecoffsymbol (symbol)->fdr != NULL
           && ecoff_ext.asym.index != indexNil)
         {
           FDR *fdr;
           unsigned int indx;
           int bigendian;
           bfd_size_type sym_base;
           union aux_ext *aux_base;

           fdr = ecoffsymbol (symbol)->fdr;
           indx = ecoff_ext.asym.index;

           /* sym_base is used to map the fdr relative indices which
              appear in the file to the position number which we are
              using.  */
           sym_base = fdr->isymBase;
           if (ecoffsymbol (symbol)->local)
             sym_base +=
              ecoff_data (abfd)->debug_info.symbolic_header.iextMax;

           /* aux_base is the start of the aux entries for this file;
              asym.index is an offset from this.  */
           aux_base = (ecoff_data (abfd)->debug_info.external_aux
                     + fdr->iauxBase);

           /* The aux entries are stored in host byte order; the
              order is indicated by a bit in the fdr.  */
           bigendian = fdr->fBigendian;

           /* This switch is basically from gcc/mips-tdump.c.  */
           switch (ecoff_ext.asym.st)
             {
             case stNil:
             case stLabel:
              break;

             case stFile:
             case stBlock:
              fprintf (file, _("\n      End+1 symbol: %ld"),
                      (long) (indx + sym_base));
              break;

             case stEnd:
              if (ecoff_ext.asym.sc == scText
                  || ecoff_ext.asym.sc == scInfo)
                fprintf (file, _("\n      First symbol: %ld"),
                        (long) (indx + sym_base));
              else
                fprintf (file, _("\n      First symbol: %ld"),
                        ((long)
                         (AUX_GET_ISYM (bigendian,
                                      &aux_base[ecoff_ext.asym.index])
                          + sym_base)));
              break;

             case stProc:
             case stStaticProc:
              if (ECOFF_IS_STAB (&ecoff_ext.asym))
                ;
              else if (ecoffsymbol (symbol)->local)
                fprintf (file, _("\n      End+1 symbol: %-7ld   Type:  %s"),
                        ((long)
                         (AUX_GET_ISYM (bigendian,
                                      &aux_base[ecoff_ext.asym.index])
                          + sym_base)),
                        ecoff_type_to_string (abfd, fdr, indx + 1));
              else
                fprintf (file, _("\n      Local symbol: %ld"),
                        ((long) indx
                         + (long) sym_base
                         + (ecoff_data (abfd)
                            ->debug_info.symbolic_header.iextMax)));
              break;

             case stStruct:
              fprintf (file, _("\n      struct; End+1 symbol: %ld"),
                      (long) (indx + sym_base));
              break;

             case stUnion:
              fprintf (file, _("\n      union; End+1 symbol: %ld"),
                      (long) (indx + sym_base));
              break;

             case stEnum:
              fprintf (file, _("\n      enum; End+1 symbol: %ld"),
                      (long) (indx + sym_base));
              break;

             default:
              if (! ECOFF_IS_STAB (&ecoff_ext.asym))
                fprintf (file, _("\n      Type: %s"),
                        ecoff_type_to_string (abfd, fdr, indx));
              break;
             }
         }
      }
      break;
    }
}

Here is the call graph for this function:

bfd_boolean _bfd_ecoff_set_arch_mach ( bfd ,
enum  bfd_architecture,
unsigned  long 
)

Definition at line 1854 of file ecoff.c.

{
  bfd_default_set_arch_mach (abfd, arch, machine);
  return arch == ecoff_backend (abfd)->arch;
}

Here is the call graph for this function:

Definition at line 192 of file ecoff.c.

{
  struct internal_filehdr *internal_f = filehdr;
  enum bfd_architecture arch;
  unsigned long mach;

  switch (internal_f->f_magic)
    {
    case MIPS_MAGIC_1:
    case MIPS_MAGIC_LITTLE:
    case MIPS_MAGIC_BIG:
      arch = bfd_arch_mips;
      mach = bfd_mach_mips3000;
      break;

    case MIPS_MAGIC_LITTLE2:
    case MIPS_MAGIC_BIG2:
      /* MIPS ISA level 2: the r6000.  */
      arch = bfd_arch_mips;
      mach = bfd_mach_mips6000;
      break;

    case MIPS_MAGIC_LITTLE3:
    case MIPS_MAGIC_BIG3:
      /* MIPS ISA level 3: the r4000.  */
      arch = bfd_arch_mips;
      mach = bfd_mach_mips4000;
      break;

    case ALPHA_MAGIC:
      arch = bfd_arch_alpha;
      mach = 0;
      break;

    default:
      arch = bfd_arch_obscure;
      mach = 0;
      break;
    }

  return bfd_default_set_arch_mach (abfd, arch, mach);
}

Here is the call graph for this function:

Definition at line 2132 of file ecoff.c.

{
  file_ptr pos;

  /* This must be done first, because bfd_set_section_contents is
     going to set output_has_begun to TRUE.  */
  if (! abfd->output_has_begun
      && ! ecoff_compute_section_file_positions (abfd))
    return FALSE;

  /* Handle the .lib section specially so that Irix 4 shared libraries
     work out.  See coff_set_section_contents in coffcode.h.  */
  if (streq (section->name, _LIB))
    {
      bfd_byte *rec, *recend;

      rec = (bfd_byte *) location;
      recend = rec + count;
      while (rec < recend)
       {
         ++section->lma;
         rec += bfd_get_32 (abfd, rec) * 4;
       }

      BFD_ASSERT (rec == recend);
    }

  if (count == 0)
    return TRUE;

  pos = section->filepos + offset;
  if (bfd_seek (abfd, pos, SEEK_SET) != 0
      || bfd_bwrite (location, count, abfd) != count)
    return FALSE;

  return TRUE;
}

Here is the call graph for this function:

Definition at line 2835 of file ecoff.c.

{
  char nextname[17];
  unsigned int i;
  struct areltdata *mapdata;
  bfd_size_type parsed_size;
  char *raw_armap;
  struct artdata *ardata;
  unsigned int count;
  char *raw_ptr;
  struct symdef *symdef_ptr;
  char *stringbase;
  bfd_size_type amt;

  /* Get the name of the first element.  */
  i = bfd_bread ((void *) nextname, (bfd_size_type) 16, abfd);
  if (i == 0)
      return TRUE;
  if (i != 16)
      return FALSE;

  if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
    return FALSE;

  /* Irix 4.0.5F apparently can use either an ECOFF armap or a
     standard COFF armap.  We could move the ECOFF armap stuff into
     bfd_slurp_armap, but that seems inappropriate since no other
     target uses this format.  Instead, we check directly for a COFF
     armap.  */
  if (CONST_STRNEQ (nextname, "/               "))
    return bfd_slurp_armap (abfd);

  /* See if the first element is an armap.  */
  if (! strneq (nextname, ecoff_backend (abfd)->armap_start, ARMAP_START_LENGTH)
      || nextname[ARMAP_HEADER_MARKER_INDEX] != ARMAP_MARKER
      || (nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
         && nextname[ARMAP_HEADER_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
      || nextname[ARMAP_OBJECT_MARKER_INDEX] != ARMAP_MARKER
      || (nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_BIG_ENDIAN
         && nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
      || ! strneq (nextname + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1))
    {
      bfd_has_map (abfd) = FALSE;
      return TRUE;
    }

  /* Make sure we have the right byte ordering.  */
  if (((nextname[ARMAP_HEADER_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
       ^ (bfd_header_big_endian (abfd)))
      || ((nextname[ARMAP_OBJECT_ENDIAN_INDEX] == ARMAP_BIG_ENDIAN)
         ^ (bfd_big_endian (abfd))))
    {
      bfd_set_error (bfd_error_wrong_format);
      return FALSE;
    }

  /* Read in the armap.  */
  ardata = bfd_ardata (abfd);
  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
  if (mapdata == NULL)
    return FALSE;
  parsed_size = mapdata->parsed_size;
  bfd_release (abfd, (void *) mapdata);

  raw_armap = bfd_alloc (abfd, parsed_size);
  if (raw_armap == NULL)
    return FALSE;

  if (bfd_bread ((void *) raw_armap, parsed_size, abfd) != parsed_size)
    {
      if (bfd_get_error () != bfd_error_system_call)
       bfd_set_error (bfd_error_malformed_archive);
      bfd_release (abfd, (void *) raw_armap);
      return FALSE;
    }

  ardata->tdata = (void *) raw_armap;

  count = H_GET_32 (abfd, raw_armap);

  ardata->symdef_count = 0;
  ardata->cache = NULL;

  /* This code used to overlay the symdefs over the raw archive data,
     but that doesn't work on a 64 bit host.  */
  stringbase = raw_armap + count * 8 + 8;

#ifdef CHECK_ARMAP_HASH
  {
    unsigned int hlog;

    /* Double check that I have the hashing algorithm right by making
       sure that every symbol can be looked up successfully.  */
    hlog = 0;
    for (i = 1; i < count; i <<= 1)
      hlog++;
    BFD_ASSERT (i == count);

    raw_ptr = raw_armap + 4;
    for (i = 0; i < count; i++, raw_ptr += 8)
      {
       unsigned int name_offset, file_offset;
       unsigned int hash, rehash, srch;

       name_offset = H_GET_32 (abfd, raw_ptr);
       file_offset = H_GET_32 (abfd, (raw_ptr + 4));
       if (file_offset == 0)
         continue;
       hash = ecoff_armap_hash (stringbase + name_offset, &rehash, count,
                             hlog);
       if (hash == i)
         continue;

       /* See if we can rehash to this location.  */
       for (srch = (hash + rehash) & (count - 1);
            srch != hash && srch != i;
            srch = (srch + rehash) & (count - 1))
         BFD_ASSERT (H_GET_32 (abfd, (raw_armap + 8 + srch * 8)) != 0);
       BFD_ASSERT (srch == i);
      }
  }

#endif /* CHECK_ARMAP_HASH */

  raw_ptr = raw_armap + 4;
  for (i = 0; i < count; i++, raw_ptr += 8)
    if (H_GET_32 (abfd, (raw_ptr + 4)) != 0)
      ++ardata->symdef_count;

  amt = ardata->symdef_count;
  amt *= sizeof (struct symdef);
  symdef_ptr = bfd_alloc (abfd, amt);
  if (!symdef_ptr)
    return FALSE;

  ardata->symdefs = (carsym *) symdef_ptr;

  raw_ptr = raw_armap + 4;
  for (i = 0; i < count; i++, raw_ptr += 8)
    {
      unsigned int name_offset, file_offset;

      file_offset = H_GET_32 (abfd, (raw_ptr + 4));
      if (file_offset == 0)
       continue;
      name_offset = H_GET_32 (abfd, raw_ptr);
      symdef_ptr->s.name = stringbase + name_offset;
      symdef_ptr->file_offset = file_offset;
      ++symdef_ptr;
    }

  ardata->first_file_filepos = bfd_tell (abfd);
  /* Pad to an even boundary.  */
  ardata->first_file_filepos += ardata->first_file_filepos % 2;

  bfd_has_map (abfd) = TRUE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 841 of file ecoff.c.

{
  const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
  const bfd_size_type external_ext_size
    = backend->debug_swap.external_ext_size;
  const bfd_size_type external_sym_size
    = backend->debug_swap.external_sym_size;
  void (* const swap_ext_in) (bfd *, void *, EXTR *)
    = backend->debug_swap.swap_ext_in;
  void (* const swap_sym_in) (bfd *, void *, SYMR *)
    = backend->debug_swap.swap_sym_in;
  bfd_size_type internal_size;
  ecoff_symbol_type *internal;
  ecoff_symbol_type *internal_ptr;
  char *eraw_src;
  char *eraw_end;
  FDR *fdr_ptr;
  FDR *fdr_end;

  /* If we've already read in the symbol table, do nothing.  */
  if (ecoff_data (abfd)->canonical_symbols != NULL)
    return TRUE;

  /* Get the symbolic information.  */
  if (! _bfd_ecoff_slurp_symbolic_info (abfd, NULL,
                                   &ecoff_data (abfd)->debug_info))
    return FALSE;
  if (bfd_get_symcount (abfd) == 0)
    return TRUE;

  internal_size = bfd_get_symcount (abfd);
  internal_size *= sizeof (ecoff_symbol_type);
  internal = bfd_alloc (abfd, internal_size);
  if (internal == NULL)
    return FALSE;

  internal_ptr = internal;
  eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
  eraw_end = (eraw_src
             + (ecoff_data (abfd)->debug_info.symbolic_header.iextMax
               * external_ext_size));
  for (; eraw_src < eraw_end; eraw_src += external_ext_size, internal_ptr++)
    {
      EXTR internal_esym;

      (*swap_ext_in) (abfd, (void *) eraw_src, &internal_esym);
      internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
                               + internal_esym.asym.iss);
      if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
                              &internal_ptr->symbol, 1,
                              internal_esym.weakext))
       return FALSE;
      /* The alpha uses a negative ifd field for section symbols.  */
      if (internal_esym.ifd >= 0)
       internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
                          + internal_esym.ifd);
      else
       internal_ptr->fdr = NULL;
      internal_ptr->local = FALSE;
      internal_ptr->native = (void *) eraw_src;
    }

  /* The local symbols must be accessed via the fdr's, because the
     string and aux indices are relative to the fdr information.  */
  fdr_ptr = ecoff_data (abfd)->debug_info.fdr;
  fdr_end = fdr_ptr + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax;
  for (; fdr_ptr < fdr_end; fdr_ptr++)
    {
      char *lraw_src;
      char *lraw_end;

      lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
                + fdr_ptr->isymBase * external_sym_size);
      lraw_end = lraw_src + fdr_ptr->csym * external_sym_size;
      for (;
          lraw_src < lraw_end;
          lraw_src += external_sym_size, internal_ptr++)
       {
         SYMR internal_sym;

         (*swap_sym_in) (abfd, (void *) lraw_src, &internal_sym);
         internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss
                                   + fdr_ptr->issBase
                                   + internal_sym.iss);
         if (!ecoff_set_symbol_info (abfd, &internal_sym,
                                  &internal_ptr->symbol, 0, 0))
           return FALSE;
         internal_ptr->fdr = fdr_ptr;
         internal_ptr->local = TRUE;
         internal_ptr->native = (void *) lraw_src;
       }
    }

  ecoff_data (abfd)->canonical_symbols = internal;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bfd_boolean _bfd_ecoff_styp_to_sec_flags ( bfd ,
void *  ,
const char *  ,
asection ,
flagword  
)

Definition at line 179 of file ecofflink.c.

{
  struct rndx_ext ext[1];

  *ext = *ext_copy;         /* Make it reasonable to do in-place.  */

  /* now the fun stuff...  */
  if (bigend) {
    intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
                | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
                                >> RNDX_BITS1_RFD_SH_BIG);
    intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
                                << RNDX_BITS1_INDEX_SH_LEFT_BIG)
                | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
                | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
  } else {
    intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
                | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
                                << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
    intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
                                >> RNDX_BITS1_INDEX_SH_LITTLE)
                | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
                | ((unsigned int) ext->r_bits[3]
                   << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
  }

#ifdef TEST
  if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
    abort ();
#endif
}

Here is the caller graph for this function:

Definition at line 218 of file ecofflink.c.

{
  RNDXR intern[1];

  *intern = *intern_copy;   /* Make it reasonable to do in-place.  */

  /* now the fun stuff...  */
  if (bigend) {
    ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
    ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
                     & RNDX_BITS1_RFD_BIG)
                    | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
                      & RNDX_BITS1_INDEX_BIG));
    ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
    ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
  } else {
    ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
    ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
                     & RNDX_BITS1_RFD_LITTLE)
                    | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
                      & RNDX_BITS1_INDEX_LITTLE));
    ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
    ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
  }

#ifdef TEST
  if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
    abort ();
#endif
}

Here is the caller graph for this function:

void _bfd_ecoff_swap_tir_in ( int  ,
const struct tir_ext ,
TIR  
)

Definition at line 66 of file ecofflink.c.

{
  struct tir_ext ext[1];

  *ext = *ext_copy;         /* Make it reasonable to do in-place.  */

  /* now the fun stuff...  */
  if (bigend) {
    intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
    intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
    intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
                     >>                TIR_BITS1_BT_SH_BIG;
    intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
                     >>                TIR_BITS_TQ4_SH_BIG;
    intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
                     >>                TIR_BITS_TQ5_SH_BIG;
    intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
                     >>                TIR_BITS_TQ0_SH_BIG;
    intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
                     >>                TIR_BITS_TQ1_SH_BIG;
    intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
                     >>                TIR_BITS_TQ2_SH_BIG;
    intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
                     >>                TIR_BITS_TQ3_SH_BIG;
  } else {
    intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
    intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
    intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
                     >>                TIR_BITS1_BT_SH_LITTLE;
    intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
                     >>                TIR_BITS_TQ4_SH_LITTLE;
    intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
                     >>                TIR_BITS_TQ5_SH_LITTLE;
    intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
                     >>                TIR_BITS_TQ0_SH_LITTLE;
    intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
                     >>                TIR_BITS_TQ1_SH_LITTLE;
    intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
                     >>                TIR_BITS_TQ2_SH_LITTLE;
    intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
                     >>                TIR_BITS_TQ3_SH_LITTLE;
  }

#ifdef TEST
  if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
    abort ();
#endif
}

Here is the caller graph for this function:

void _bfd_ecoff_swap_tir_out ( int  ,
const TIR ,
struct tir_ext  
)

Definition at line 123 of file ecofflink.c.

{
  TIR intern[1];

  *intern = *intern_copy;   /* Make it reasonable to do in-place.  */

  /* now the fun stuff...  */
  if (bigend) {
    ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
                     | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
                     | ((intern->bt << TIR_BITS1_BT_SH_BIG)
                       & TIR_BITS1_BT_BIG));
    ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
                     & TIR_BITS_TQ4_BIG)
                    | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
                      & TIR_BITS_TQ5_BIG));
    ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
                     & TIR_BITS_TQ0_BIG)
                    | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
                      & TIR_BITS_TQ1_BIG));
    ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
                     & TIR_BITS_TQ2_BIG)
                    | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
                      & TIR_BITS_TQ3_BIG));
  } else {
    ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
                     | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
                     | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
                       & TIR_BITS1_BT_LITTLE));
    ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
                     & TIR_BITS_TQ4_LITTLE)
                    | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
                      & TIR_BITS_TQ5_LITTLE));
    ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
                     & TIR_BITS_TQ0_LITTLE)
                    | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
                      & TIR_BITS_TQ1_LITTLE));
    ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
                     & TIR_BITS_TQ2_LITTLE)
                    | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
                      & TIR_BITS_TQ3_LITTLE));
  }

#ifdef TEST
  if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
    abort ();
#endif
}
bfd_boolean _bfd_ecoff_write_armap ( bfd ,
unsigned  int,
struct orl ,
unsigned  int,
int   
)

Definition at line 2998 of file ecoff.c.

{
  unsigned int hashsize, hashlog;
  bfd_size_type symdefsize;
  int padit;
  unsigned int stringsize;
  unsigned int mapsize;
  file_ptr firstreal;
  struct ar_hdr hdr;
  struct stat statbuf;
  unsigned int i;
  bfd_byte temp[4];
  bfd_byte *hashtable;
  bfd *current;
  bfd *last_elt;

  /* Ultrix appears to use as a hash table size the least power of two
     greater than twice the number of entries.  */
  for (hashlog = 0; ((unsigned int) 1 << hashlog) <= 2 * orl_count; hashlog++)
    ;
  hashsize = 1 << hashlog;

  symdefsize = hashsize * 8;
  padit = stridx % 2;
  stringsize = stridx + padit;

  /* Include 8 bytes to store symdefsize and stringsize in output.  */
  mapsize = symdefsize + stringsize + 8;

  firstreal = SARMAG + sizeof (struct ar_hdr) + mapsize + elength;

  memset ((void *) &hdr, 0, sizeof hdr);

  /* Work out the ECOFF armap name.  */
  strcpy (hdr.ar_name, ecoff_backend (abfd)->armap_start);
  hdr.ar_name[ARMAP_HEADER_MARKER_INDEX] = ARMAP_MARKER;
  hdr.ar_name[ARMAP_HEADER_ENDIAN_INDEX] =
    (bfd_header_big_endian (abfd)
     ? ARMAP_BIG_ENDIAN
     : ARMAP_LITTLE_ENDIAN);
  hdr.ar_name[ARMAP_OBJECT_MARKER_INDEX] = ARMAP_MARKER;
  hdr.ar_name[ARMAP_OBJECT_ENDIAN_INDEX] =
    bfd_big_endian (abfd) ? ARMAP_BIG_ENDIAN : ARMAP_LITTLE_ENDIAN;
  memcpy (hdr.ar_name + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1);

  /* Write the timestamp of the archive header to be just a little bit
     later than the timestamp of the file, otherwise the linker will
     complain that the index is out of date.  Actually, the Ultrix
     linker just checks the archive name; the GNU linker may check the
     date.  */
  stat (abfd->filename, &statbuf);
  sprintf (hdr.ar_date, "%ld", (long) (statbuf.st_mtime + 60));

  /* The DECstation uses zeroes for the uid, gid and mode of the
     armap.  */
  hdr.ar_uid[0] = '0';
  hdr.ar_gid[0] = '0';
  /* Building gcc ends up extracting the armap as a file - twice.  */
  hdr.ar_mode[0] = '6';
  hdr.ar_mode[1] = '4';
  hdr.ar_mode[2] = '4';

  sprintf (hdr.ar_size, "%-10d", (int) mapsize);

  hdr.ar_fmag[0] = '`';
  hdr.ar_fmag[1] = '\012';

  /* Turn all null bytes in the header into spaces.  */
  for (i = 0; i < sizeof (struct ar_hdr); i++)
   if (((char *) (&hdr))[i] == '\0')
     (((char *) (&hdr))[i]) = ' ';

  if (bfd_bwrite ((void *) &hdr, (bfd_size_type) sizeof (struct ar_hdr), abfd)
      != sizeof (struct ar_hdr))
    return FALSE;

  H_PUT_32 (abfd, hashsize, temp);
  if (bfd_bwrite ((void *) temp, (bfd_size_type) 4, abfd) != 4)
    return FALSE;

  hashtable = bfd_zalloc (abfd, symdefsize);
  if (!hashtable)
    return FALSE;

  current = abfd->archive_head;
  last_elt = current;
  for (i = 0; i < orl_count; i++)
    {
      unsigned int hash, rehash;

      /* Advance firstreal to the file position of this archive
        element.  */
      if (map[i].u.abfd != last_elt)
       {
         do
           {
             firstreal += arelt_size (current) + sizeof (struct ar_hdr);
             firstreal += firstreal % 2;
             current = current->next;
           }
         while (current != map[i].u.abfd);
       }

      last_elt = current;

      hash = ecoff_armap_hash (*map[i].name, &rehash, hashsize, hashlog);
      if (H_GET_32 (abfd, (hashtable + (hash * 8) + 4)) != 0)
       {
         unsigned int srch;

         /* The desired slot is already taken.  */
         for (srch = (hash + rehash) & (hashsize - 1);
              srch != hash;
              srch = (srch + rehash) & (hashsize - 1))
           if (H_GET_32 (abfd, (hashtable + (srch * 8) + 4)) == 0)
             break;

         BFD_ASSERT (srch != hash);

         hash = srch;
       }

      H_PUT_32 (abfd, map[i].namidx, (hashtable + hash * 8));
      H_PUT_32 (abfd, firstreal, (hashtable + hash * 8 + 4));
    }

  if (bfd_bwrite ((void *) hashtable, symdefsize, abfd) != symdefsize)
    return FALSE;

  bfd_release (abfd, hashtable);

  /* Now write the strings.  */
  H_PUT_32 (abfd, stringsize, temp);
  if (bfd_bwrite ((void *) temp, (bfd_size_type) 4, abfd) != 4)
    return FALSE;
  for (i = 0; i < orl_count; i++)
    {
      bfd_size_type len;

      len = strlen (*map[i].name) + 1;
      if (bfd_bwrite ((void *) (*map[i].name), len, abfd) != len)
       return FALSE;
    }

  /* The spec sez this should be a newline.  But in order to be
     bug-compatible for DECstation ar we use a null.  */
  if (padit)
    {
      if (bfd_bwrite ("", (bfd_size_type) 1, abfd) != 1)
       return FALSE;
    }

  return TRUE;
}

Here is the call graph for this function:

Definition at line 2315 of file ecoff.c.

{
  const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
  const bfd_vma round = backend->round;
  const bfd_size_type filhsz = bfd_coff_filhsz (abfd);
  const bfd_size_type aoutsz = bfd_coff_aoutsz (abfd);
  const bfd_size_type scnhsz = bfd_coff_scnhsz (abfd);
  const bfd_size_type external_hdr_size
    = backend->debug_swap.external_hdr_size;
  const bfd_size_type external_reloc_size = backend->external_reloc_size;
  void (* const adjust_reloc_out) (bfd *, const arelent *, struct internal_reloc *)
    = backend->adjust_reloc_out;
  void (* const swap_reloc_out) (bfd *, const struct internal_reloc *, void *)
    = backend->swap_reloc_out;
  struct ecoff_debug_info * const debug = &ecoff_data (abfd)->debug_info;
  HDRR * const symhdr = &debug->symbolic_header;
  asection *current;
  unsigned int count;
  bfd_size_type reloc_size;
  bfd_size_type text_size;
  bfd_vma text_start;
  bfd_boolean set_text_start;
  bfd_size_type data_size;
  bfd_vma data_start;
  bfd_boolean set_data_start;
  bfd_size_type bss_size;
  void * buff = NULL;
  void * reloc_buff = NULL;
  struct internal_filehdr internal_f;
  struct internal_aouthdr internal_a;
  int i;

  /* Determine where the sections and relocs will go in the output
     file.  */
  reloc_size = ecoff_compute_reloc_file_positions (abfd);

  count = 1;
  for (current = abfd->sections;
       current != NULL;
       current = current->next)
    {
      current->target_index = count;
      ++count;
    }

  if ((abfd->flags & D_PAGED) != 0)
    text_size = _bfd_ecoff_sizeof_headers (abfd, NULL);
  else
    text_size = 0;
  text_start = 0;
  set_text_start = FALSE;
  data_size = 0;
  data_start = 0;
  set_data_start = FALSE;
  bss_size = 0;

  /* Write section headers to the file.  */

  /* Allocate buff big enough to hold a section header,
     file header, or a.out header.  */
  {
    bfd_size_type siz;

    siz = scnhsz;
    if (siz < filhsz)
      siz = filhsz;
    if (siz < aoutsz)
      siz = aoutsz;
    buff = bfd_malloc (siz);
    if (buff == NULL)
      goto error_return;
  }

  internal_f.f_nscns = 0;
  if (bfd_seek (abfd, (file_ptr) (filhsz + aoutsz), SEEK_SET) != 0)
    goto error_return;

  for (current = abfd->sections;
       current != NULL;
       current = current->next)
    {
      struct internal_scnhdr section;
      bfd_vma vma;

      ++internal_f.f_nscns;

      strncpy (section.s_name, current->name, sizeof section.s_name);

      /* This seems to be correct for Irix 4 shared libraries.  */
      vma = bfd_get_section_vma (abfd, current);
      if (streq (current->name, _LIB))
       section.s_vaddr = 0;
      else
       section.s_vaddr = vma;

      section.s_paddr = current->lma;
      section.s_size = current->size;

      /* If this section is unloadable then the scnptr will be 0.  */
      if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
       section.s_scnptr = 0;
      else
       section.s_scnptr = current->filepos;
      section.s_relptr = current->rel_filepos;

      /* FIXME: the lnnoptr of the .sbss or .sdata section of an
        object file produced by the assembler is supposed to point to
        information about how much room is required by objects of
        various different sizes.  I think this only matters if we
        want the linker to compute the best size to use, or
        something.  I don't know what happens if the information is
        not present.  */
      if (! streq (current->name, _PDATA))
       section.s_lnnoptr = 0;
      else
       {
         /* The Alpha ECOFF .pdata section uses the lnnoptr field to
            hold the number of entries in the section (each entry is
            8 bytes).  We stored this in the line_filepos field in
            ecoff_compute_section_file_positions.  */
         section.s_lnnoptr = current->line_filepos;
       }

      section.s_nreloc = current->reloc_count;
      section.s_nlnno = 0;
      section.s_flags = ecoff_sec_to_styp_flags (current->name,
                                           current->flags);

      if (bfd_coff_swap_scnhdr_out (abfd, (void *) &section, buff) == 0
         || bfd_bwrite (buff, scnhsz, abfd) != scnhsz)
       goto error_return;

      if ((section.s_flags & STYP_TEXT) != 0
         || ((section.s_flags & STYP_RDATA) != 0
             && ecoff_data (abfd)->rdata_in_text)
         || section.s_flags == STYP_PDATA
         || (section.s_flags & STYP_DYNAMIC) != 0
         || (section.s_flags & STYP_LIBLIST) != 0
         || (section.s_flags & STYP_RELDYN) != 0
         || section.s_flags == STYP_CONFLIC
         || (section.s_flags & STYP_DYNSTR) != 0
         || (section.s_flags & STYP_DYNSYM) != 0
         || (section.s_flags & STYP_HASH) != 0
         || (section.s_flags & STYP_ECOFF_INIT) != 0
         || (section.s_flags & STYP_ECOFF_FINI) != 0
         || section.s_flags == STYP_RCONST)
       {
         text_size += current->size;
         if (! set_text_start || text_start > vma)
           {
             text_start = vma;
             set_text_start = TRUE;
           }
       }
      else if ((section.s_flags & STYP_RDATA) != 0
              || (section.s_flags & STYP_DATA) != 0
              || (section.s_flags & STYP_LITA) != 0
              || (section.s_flags & STYP_LIT8) != 0
              || (section.s_flags & STYP_LIT4) != 0
              || (section.s_flags & STYP_SDATA) != 0
              || section.s_flags == STYP_XDATA
              || (section.s_flags & STYP_GOT) != 0)
       {
         data_size += current->size;
         if (! set_data_start || data_start > vma)
           {
             data_start = vma;
             set_data_start = TRUE;
           }
       }
      else if ((section.s_flags & STYP_BSS) != 0
              || (section.s_flags & STYP_SBSS) != 0)
       bss_size += current->size;
      else if (section.s_flags == 0
              || (section.s_flags & STYP_ECOFF_LIB) != 0
              || section.s_flags == STYP_COMMENT)
       /* Do nothing.  */ ;
      else
       abort ();
    }

  /* Set up the file header.  */
  internal_f.f_magic = ecoff_get_magic (abfd);

  /* We will NOT put a fucking timestamp in the header here. Every
     time you put it back, I will come in and take it out again.  I'm
     sorry.  This field does not belong here.  We fill it with a 0 so
     it compares the same but is not a reasonable time. --
     gnu@cygnus.com.  */
  internal_f.f_timdat = 0;

  if (bfd_get_symcount (abfd) != 0)
    {
      /* The ECOFF f_nsyms field is not actually the number of
        symbols, it's the size of symbolic information header.  */
      internal_f.f_nsyms = external_hdr_size;
      internal_f.f_symptr = ecoff_data (abfd)->sym_filepos;
    }
  else
    {
      internal_f.f_nsyms = 0;
      internal_f.f_symptr = 0;
    }

  internal_f.f_opthdr = aoutsz;

  internal_f.f_flags = F_LNNO;
  if (reloc_size == 0)
    internal_f.f_flags |= F_RELFLG;
  if (bfd_get_symcount (abfd) == 0)
    internal_f.f_flags |= F_LSYMS;
  if (abfd->flags & EXEC_P)
    internal_f.f_flags |= F_EXEC;

  if (bfd_little_endian (abfd))
    internal_f.f_flags |= F_AR32WR;
  else
    internal_f.f_flags |= F_AR32W;

  /* Set up the ``optional'' header.  */
  if ((abfd->flags & D_PAGED) != 0)
    internal_a.magic = ECOFF_AOUT_ZMAGIC;
  else
    internal_a.magic = ECOFF_AOUT_OMAGIC;

  /* FIXME: Is this really correct?  */
  internal_a.vstamp = symhdr->vstamp;

  /* At least on Ultrix, these have to be rounded to page boundaries.
     FIXME: Is this true on other platforms?  */
  if ((abfd->flags & D_PAGED) != 0)
    {
      internal_a.tsize = (text_size + round - 1) &~ (round - 1);
      internal_a.text_start = text_start &~ (round - 1);
      internal_a.dsize = (data_size + round - 1) &~ (round - 1);
      internal_a.data_start = data_start &~ (round - 1);
    }
  else
    {
      internal_a.tsize = text_size;
      internal_a.text_start = text_start;
      internal_a.dsize = data_size;
      internal_a.data_start = data_start;
    }

  /* On Ultrix, the initial portions of the .sbss and .bss segments
     are at the end of the data section.  The bsize field in the
     optional header records how many bss bytes are required beyond
     those in the data section.  The value is not rounded to a page
     boundary.  */
  if (bss_size < internal_a.dsize - data_size)
    bss_size = 0;
  else
    bss_size -= internal_a.dsize - data_size;
  internal_a.bsize = bss_size;
  internal_a.bss_start = internal_a.data_start + internal_a.dsize;

  internal_a.entry = bfd_get_start_address (abfd);

  internal_a.gp_value = ecoff_data (abfd)->gp;

  internal_a.gprmask = ecoff_data (abfd)->gprmask;
  internal_a.fprmask = ecoff_data (abfd)->fprmask;
  for (i = 0; i < 4; i++)
    internal_a.cprmask[i] = ecoff_data (abfd)->cprmask[i];

  /* Let the backend adjust the headers if necessary.  */
  if (backend->adjust_headers)
    {
      if (! (*backend->adjust_headers) (abfd, &internal_f, &internal_a))
       goto error_return;
    }

  /* Write out the file header and the optional header.  */
  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    goto error_return;

  bfd_coff_swap_filehdr_out (abfd, (void *) &internal_f, buff);
  if (bfd_bwrite (buff, filhsz, abfd) != filhsz)
    goto error_return;

  bfd_coff_swap_aouthdr_out (abfd, (void *) &internal_a, buff);
  if (bfd_bwrite (buff, aoutsz, abfd) != aoutsz)
    goto error_return;

  /* Build the external symbol information.  This must be done before
     writing out the relocs so that we know the symbol indices.  We
     don't do this if this BFD was created by the backend linker,
     since it will have already handled the symbols and relocs.  */
  if (! ecoff_data (abfd)->linker)
    {
      symhdr->iextMax = 0;
      symhdr->issExtMax = 0;
      debug->external_ext = debug->external_ext_end = NULL;
      debug->ssext = debug->ssext_end = NULL;
      if (! bfd_ecoff_debug_externals (abfd, debug, &backend->debug_swap,
                                   (abfd->flags & EXEC_P) == 0,
                                   ecoff_get_extr, ecoff_set_index))
       goto error_return;

      /* Write out the relocs.  */
      for (current = abfd->sections;
          current != NULL;
          current = current->next)
       {
         arelent **reloc_ptr_ptr;
         arelent **reloc_end;
         char *out_ptr;
         bfd_size_type amt;

         if (current->reloc_count == 0)
           continue;

         amt = current->reloc_count * external_reloc_size;
         reloc_buff = bfd_alloc (abfd, amt);
         if (reloc_buff == NULL)
           goto error_return;

         reloc_ptr_ptr = current->orelocation;
         reloc_end = reloc_ptr_ptr + current->reloc_count;
         out_ptr = (char *) reloc_buff;

         for (;
              reloc_ptr_ptr < reloc_end;
              reloc_ptr_ptr++, out_ptr += external_reloc_size)
           {
             arelent *reloc;
             asymbol *sym;
             struct internal_reloc in;

             memset ((void *) &in, 0, sizeof in);

             reloc = *reloc_ptr_ptr;
             sym = *reloc->sym_ptr_ptr;

             /* If the howto field has not been initialised then skip this reloc.
               This assumes that an error message has been issued elsewhere.  */
             if (reloc->howto == NULL)
              continue;

             in.r_vaddr = (reloc->address
                         + bfd_get_section_vma (abfd, current));
             in.r_type = reloc->howto->type;

             if ((sym->flags & BSF_SECTION_SYM) == 0)
              {
                in.r_symndx = ecoff_get_sym_index (*reloc->sym_ptr_ptr);
                in.r_extern = 1;
              }
             else
              {
                const char *name;
                unsigned int i;
                static struct
                {
                  const char * name;
                  long r_symndx;
                }
                section_symndx [] =
                {
                  { _TEXT,   RELOC_SECTION_TEXT   },
                  { _RDATA,  RELOC_SECTION_RDATA  },
                  { _DATA,   RELOC_SECTION_DATA   },
                  { _SDATA,  RELOC_SECTION_SDATA  },
                  { _SBSS,   RELOC_SECTION_SBSS   },
                  { _BSS,    RELOC_SECTION_BSS    },
                  { _INIT,   RELOC_SECTION_INIT   },
                  { _LIT8,   RELOC_SECTION_LIT8   },
                  { _LIT4,   RELOC_SECTION_LIT4   },
                  { _XDATA,  RELOC_SECTION_XDATA  },
                  { _PDATA,  RELOC_SECTION_PDATA  },
                  { _FINI,   RELOC_SECTION_FINI   },
                  { _LITA,   RELOC_SECTION_LITA   },
                  { "*ABS*", RELOC_SECTION_ABS    },
                  { _RCONST, RELOC_SECTION_RCONST }
                };

                name = bfd_get_section_name (abfd, bfd_get_section (sym));

                for (i = 0; i < ARRAY_SIZE (section_symndx); i++)
                  if (streq (name, section_symndx[i].name))
                    {
                     in.r_symndx = section_symndx[i].r_symndx;
                     break;
                    }

                if (i == ARRAY_SIZE (section_symndx))
                  abort ();
                in.r_extern = 0;
              }

             (*adjust_reloc_out) (abfd, reloc, &in);

             (*swap_reloc_out) (abfd, &in, (void *) out_ptr);
           }

         if (bfd_seek (abfd, current->rel_filepos, SEEK_SET) != 0)
           goto error_return;
         amt = current->reloc_count * external_reloc_size;
         if (bfd_bwrite (reloc_buff, amt, abfd) != amt)
           goto error_return;
         bfd_release (abfd, reloc_buff);
         reloc_buff = NULL;
       }

      /* Write out the symbolic debugging information.  */
      if (bfd_get_symcount (abfd) > 0)
       {
         /* Write out the debugging information.  */
         if (! bfd_ecoff_write_debug (abfd, debug, &backend->debug_swap,
                                   ecoff_data (abfd)->sym_filepos))
           goto error_return;
       }
    }

  /* The .bss section of a demand paged executable must receive an
     entire page.  If there are symbols, the symbols will start on the
     next page.  If there are no symbols, we must fill out the page by
     hand.  */
  if (bfd_get_symcount (abfd) == 0
      && (abfd->flags & EXEC_P) != 0
      && (abfd->flags & D_PAGED) != 0)
    {
      char c;

      if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
                  SEEK_SET) != 0)
       goto error_return;
      if (bfd_bread (&c, (bfd_size_type) 1, abfd) == 0)
       c = 0;
      if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
                  SEEK_SET) != 0)
       goto error_return;
      if (bfd_bwrite (&c, (bfd_size_type) 1, abfd) != 1)
       goto error_return;
    }

  if (reloc_buff != NULL)
    bfd_release (abfd, reloc_buff);
  if (buff != NULL)
    free (buff);
  return TRUE;
 error_return:
  if (reloc_buff != NULL)
    bfd_release (abfd, reloc_buff);
  if (buff != NULL)
    free (buff);
  return FALSE;
}

Here is the call graph for this function: