* coffcode.h (coff_swap_aux_in): lint, (coff_print_symbol): prints
[deliverable/binutils-gdb.git] / bfd / coff-code.h
index c122b9f10364853d2fef1ce3121e5c667ec1e387..904023652639c3b1ed29b94f2a268a9abdb1d338 100755 (executable)
@@ -40,6 +40,12 @@ You should have received a copy of the GNU General Public License along with
 
 #define sp(x) bfd_h_put_x(abfd, x, &x)
 
+#ifndef I960
+#define GDB_EXPORT static
+#else
+#define GDB_EXPORT  /* nothing */
+#endif
+
 PROTO(static void,force_indices_file_symbol_relative,(bfd *abfd,
                                                      struct internal_syment *symtab));
 
@@ -65,7 +71,607 @@ DEFUN(set_index,(symbol, idx),
 
 
 
-#include "coffish.h"
+
+/* All the swapping routines:
+*/
+
+
+GDB_EXPORT
+void
+DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
+      bfd            *abfd AND
+      RELOC *reloc_src AND
+      struct internal_reloc *reloc_dst)
+{
+  reloc_dst->r_vaddr = bfd_h_getlong(abfd, reloc_src->r_vaddr);
+  reloc_dst->r_symndx = bfd_h_getlong(abfd, reloc_src->r_symndx);
+  reloc_dst->r_type = bfd_h_getshort(abfd, reloc_src->r_type);
+#if M88
+  reloc_dst->r_offset = bfd_h_getshort(abfd, reloc_src->r_offset);
+#endif
+}
+
+GDB_EXPORT
+ void
+DEFUN(bfd_swap_reloc_out,(abfd, reloc_src, reloc_dst),
+      bfd            *abfd AND
+      struct internal_reloc *reloc_src AND
+      struct external_reloc *reloc_dst)
+{
+  bfd_h_putlong(abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
+  bfd_h_putlong(abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
+  bfd_h_putshort(abfd, reloc_src->r_type, reloc_dst->r_type);
+#if M88
+  bfd_h_putshort(abfd, reloc_src->r_offset, reloc_dst->r_offset);
+#endif
+
+}
+
+GDB_EXPORT  void 
+DEFUN(bfd_swap_filehdr_in,(abfd, filehdr_src, filehdr_dst),
+      bfd            *abfd AND
+      FILHDR         *filehdr_src AND
+      struct internal_filehdr *filehdr_dst)
+{
+  filehdr_dst->f_magic = bfd_h_get_x(abfd, filehdr_src->f_magic);
+  filehdr_dst->f_nscns = bfd_h_get_x(abfd,filehdr_src-> f_nscns);
+  filehdr_dst->f_timdat = bfd_h_get_x(abfd,filehdr_src-> f_timdat);
+  filehdr_dst->f_symptr = bfd_h_get_x(abfd,filehdr_src-> f_symptr);
+  filehdr_dst->f_nsyms = bfd_h_get_x(abfd,filehdr_src-> f_nsyms);
+  filehdr_dst->f_opthdr = bfd_h_get_x(abfd,filehdr_src-> f_opthdr);
+  filehdr_dst->f_flags = bfd_h_get_x(abfd,filehdr_src-> f_flags);
+}
+
+GDB_EXPORT  void 
+DEFUN(bfd_swap_filehdr_out,(abfd, filehdr_in, filehdr_out),
+      bfd            *abfd AND
+      struct internal_filehdr *filehdr_in AND
+      FILHDR         *filehdr_out)
+{
+  bfd_h_put_x(abfd, filehdr_in->f_magic, filehdr_out->f_magic);
+  bfd_h_put_x(abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
+  bfd_h_put_x(abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
+  bfd_h_put_x(abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
+  bfd_h_put_x(abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
+  bfd_h_put_x(abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
+  bfd_h_put_x(abfd, filehdr_in->f_flags, filehdr_out->f_flags);
+}
+
+
+GDB_EXPORT 
+void 
+DEFUN(bfd_coff_swap_sym_in,(abfd, ext, in),
+      bfd            *abfd AND
+      SYMENT *ext AND
+      struct internal_syment      *in)
+{
+  if( ext->e.e_name[0] == 0) {
+    in->_n._n_n._n_zeroes = 0;
+    in->_n._n_n._n_offset = bfd_h_getlong(abfd, ext->e.e.e_offset);
+  }
+  else {
+    memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
+  }
+  in->n_value = bfd_h_get_x(abfd, ext->e_value);
+  in->n_scnum = bfd_h_get_x(abfd, ext->e_scnum);
+  in->n_type = bfd_h_get_x(abfd, ext->e_type);
+  in->n_sclass = bfd_h_get_x(abfd, ext->e_sclass);
+  in->n_numaux = bfd_h_get_x(abfd, ext->e_numaux);
+}
+
+GDB_EXPORT void 
+DEFUN(bfd_coff_swap_sym_out,(abfd,in,  ext),
+      bfd            *abfd AND
+      struct internal_syment      *in AND
+      SYMENT *ext)
+{
+  if(in->_n._n_name[0] == 0) {
+    bfd_h_putlong(abfd, 0, ext->e.e.e_zeroes);
+    bfd_h_putlong(abfd, in->_n._n_n._n_offset,  ext->e.e.e_offset);
+  }
+  else {
+    memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
+  }
+  bfd_h_put_x(abfd,  in->n_value , ext->e_value);
+  bfd_h_put_x(abfd,  in->n_scnum , ext->e_scnum);
+  bfd_h_put_x(abfd,  in->n_type , ext->e_type);
+  bfd_h_put_x(abfd,  in->n_sclass , ext->e_sclass);
+  bfd_h_put_x(abfd,  in->n_numaux , ext->e_numaux);
+}
+
+GDB_EXPORT void
+DEFUN(bfd_coff_swap_aux_in,(abfd, ext, type, class, in),
+      bfd            *abfd AND
+      AUXENT    *ext AND
+      int             type AND
+      int             class AND
+      union internal_auxent  *in)
+{
+  switch (class) {
+  case C_FILE:
+    if (ext->x_file.x_fname[0] == 0) {
+      in->x_file.x_n.x_zeroes = 0;
+      in->x_file.x_n.x_offset  = bfd_h_getlong(abfd, ext->x_file.x_n.x_offset);
+    }
+
+    break;
+  case C_STAT:
+#ifdef C_LEAFSTAT
+  case C_LEAFSTAT:
+#endif
+  case C_HIDDEN:
+    if (type == T_NULL) {
+      in->x_scn.x_scnlen = bfd_h_get_x(abfd, ext->x_scn.x_scnlen);
+      in->x_scn.x_nreloc = bfd_h_get_x(abfd, ext->x_scn.x_nreloc);
+      in->x_scn.x_nlinno = bfd_h_get_x(abfd, ext->x_scn.x_nlinno);
+      break;
+    }
+  default:
+    in->x_sym.x_tagndx = bfd_h_get_x(abfd, ext->x_sym.x_tagndx);
+    in->x_sym.x_tvndx = bfd_h_get_x(abfd, ext->x_sym.x_tvndx);
+
+    if (ISARY(type) || class == C_BLOCK) {
+      in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+      in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+      in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+      in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+    }
+    else {
+      in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+      in->x_sym.x_fcnary.x_fcn.x_endndx = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
+    }
+    if (ISFCN(type)) {
+      in->x_sym.x_misc.x_fsize = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_fsize);
+    }
+    else {
+      in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_lnno);
+      in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_size);
+    }
+  }
+}
+
+GDB_EXPORT void
+DEFUN(bfd_coff_swap_aux_out,(abfd, in, type, class, ext),
+  bfd   *abfd AND
+  union internal_auxent *in AND
+  int    type AND
+  int    class AND
+  AUXENT *ext)
+{
+  switch (class) {
+  case C_FILE:
+    if (in->x_file.x_fname[0] == 0) {
+      bfd_h_put_x(abfd, 0, ext->x_file.x_n.x_zeroes );
+      bfd_h_put_x(abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+    }
+
+    break;
+  case C_STAT:
+#ifdef C_LEAFSTAT
+  case C_LEAFSTAT:
+#endif
+  case C_HIDDEN:
+    if (type == T_NULL) {
+      bfd_h_put_x(abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen);
+      bfd_h_put_x(abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc);
+      bfd_h_put_x(abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno);
+      break;
+    }
+  default:
+    bfd_h_put_x(abfd, in->x_sym.x_tagndx, ext->x_sym.x_tagndx);
+    bfd_h_put_x(abfd, in->x_sym.x_tvndx , ext->x_sym.x_tvndx);
+
+    if (ISARY(type) || class == C_BLOCK) {
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+    }
+    else {
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+      bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx, ext->x_sym.x_fcnary.x_fcn.x_endndx);
+    }
+    if (ISFCN(type)) {
+      bfd_h_put_x(abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
+    }
+    else {
+      bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext->x_sym.x_misc.x_lnsz.x_lnno);
+      bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext->x_sym.x_misc.x_lnsz.x_size);
+    }
+  }
+}
+
+GDB_EXPORT void
+DEFUN(bfd_coff_swap_lineno_in,(abfd, ext, in),
+      bfd            *abfd AND
+      LINENO *ext AND
+      struct internal_lineno      *in)
+{
+    in->l_addr.l_symndx = bfd_h_get_x(abfd, ext->l_addr.l_symndx);
+    in->l_lnno = bfd_h_get_x(abfd, ext->l_lnno);
+}
+
+GDB_EXPORT void
+DEFUN(bfd_coff_swap_lineno_out,(abfd, in, ext),
+      bfd            *abfd AND
+      struct internal_lineno      *in AND
+      struct external_lineno *ext)
+{
+  bfd_h_put_x(abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
+  bfd_h_put_x(abfd, in->l_lnno, ext->l_lnno);
+}
+
+
+
+
+GDB_EXPORT void 
+DEFUN(bfd_swap_aouthdr_in,(abfd, aouthdr_ext, aouthdr_int),
+      bfd            *abfd AND
+      AOUTHDR        *aouthdr_ext AND
+      struct internal_aouthdr *aouthdr_int)
+{
+  aouthdr_int->magic = bfd_h_get_x(abfd, aouthdr_ext->magic);
+  aouthdr_int->vstamp = bfd_h_get_x(abfd, aouthdr_ext->vstamp);
+  aouthdr_int->tsize = bfd_h_get_x(abfd, aouthdr_ext->tsize);
+  aouthdr_int->dsize = bfd_h_get_x(abfd, aouthdr_ext->dsize);
+  aouthdr_int->bsize = bfd_h_get_x(abfd, aouthdr_ext->bsize);
+  aouthdr_int->entry = bfd_h_get_x(abfd, aouthdr_ext->entry);
+  aouthdr_int->text_start = bfd_h_get_x(abfd, aouthdr_ext->text_start);
+  aouthdr_int->data_start = bfd_h_get_x(abfd, aouthdr_ext->data_start);
+#ifdef I960
+  aouthdr_int->tagentries = bfd_h_get_x(abfd, aouthdr_ext->tagentries);
+#endif
+}
+
+GDB_EXPORT void 
+DEFUN(bfd_swap_aouthdr_out,(abfd, aouthdr_in, aouthdr_out),
+      bfd            *abfd AND
+      struct internal_aouthdr *aouthdr_in AND
+      AOUTHDR        *aouthdr_out)
+{
+  bfd_h_put_x(abfd, aouthdr_in->magic, aouthdr_out->magic);
+  bfd_h_put_x(abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
+  bfd_h_put_x(abfd, aouthdr_in->tsize, aouthdr_out->tsize);
+  bfd_h_put_x(abfd, aouthdr_in->dsize, aouthdr_out->dsize);
+  bfd_h_put_x(abfd, aouthdr_in->bsize, aouthdr_out->bsize);
+  bfd_h_put_x(abfd, aouthdr_in->entry, aouthdr_out->entry);
+  bfd_h_put_x(abfd, aouthdr_in->text_start, aouthdr_out->text_start);
+  bfd_h_put_x(abfd, aouthdr_in->data_start, aouthdr_out->data_start);
+#ifdef I960
+  bfd_h_put_x(abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
+#endif
+}
+
+GDB_EXPORT void 
+DEFUN(bfd_coff_swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int),
+      bfd            *abfd AND
+      SCNHDR         *scnhdr_ext AND
+      struct internal_scnhdr *scnhdr_int)
+{
+  memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
+  scnhdr_int->s_vaddr = bfd_h_get_x(abfd, scnhdr_ext->s_vaddr);
+  scnhdr_int->s_paddr = bfd_h_get_x(abfd, scnhdr_ext->s_paddr);
+  scnhdr_int->s_size = bfd_h_get_x(abfd, scnhdr_ext->s_size);
+  scnhdr_int->s_scnptr = bfd_h_get_x(abfd, scnhdr_ext->s_scnptr);
+  scnhdr_int->s_relptr = bfd_h_get_x(abfd, scnhdr_ext->s_relptr);
+  scnhdr_int->s_lnnoptr = bfd_h_get_x(abfd, scnhdr_ext->s_lnnoptr);
+  scnhdr_int->s_nreloc = bfd_h_get_x(abfd, scnhdr_ext->s_nreloc);
+  scnhdr_int->s_nlnno = bfd_h_get_x(abfd, scnhdr_ext->s_nlnno);
+  scnhdr_int->s_flags = bfd_h_get_x(abfd, scnhdr_ext->s_flags);
+#ifdef I960
+  scnhdr_int->s_align = bfd_h_get_x(abfd, scnhdr_ext->s_align);
+#endif
+}
+
+static void 
+DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext),
+      bfd            *abfd AND
+      struct internal_scnhdr *scnhdr_int AND
+      SCNHDR         *scnhdr_ext)
+{
+  memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
+  bfd_h_put_x(abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
+  bfd_h_put_x(abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
+  bfd_h_put_x(abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
+  bfd_h_put_x(abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
+  bfd_h_put_x(abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
+  bfd_h_put_x(abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
+  bfd_h_put_x(abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
+  bfd_h_put_x(abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
+  bfd_h_put_x(abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
+#ifdef I960
+  bfd_h_put_x(abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
+#endif
+}
+
+/*
+   initialize a section structure with information peculiar to this
+   particular implementation of coff
+*/
+
+static          boolean
+DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore),
+      bfd            *abfd_ignore AND
+      asection       *section_ignore)
+{
+#ifdef MC88MAGIC
+  /* FIXME, shouldn't this ifdef be on something that says we are
+     actually COMPILING FOR an 88K coff file, rather than simply
+     knowing its magic number? */
+  /* Align to at least 16 bytes */
+  section_ignore->alignment_power = 4;
+#endif
+#if M68
+  section_ignore->alignment_power = 3;
+#endif
+  return true;
+}
+
+/* Take a section header read from a coff file (in HOST byte order),
+   and make a BFD "section" out of it.  */
+static          boolean
+DEFUN(make_a_section_from_file,(abfd, hdr),
+      bfd            *abfd AND
+      struct internal_scnhdr  *hdr)
+{
+    asection       *return_section;
+
+    {
+       /* Assorted wastage to null-terminate the name, thanks AT&T! */
+       char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1);
+       if (name == NULL) {
+           bfd_error = no_memory;
+           return false;
+       }
+       strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
+       name[sizeof (hdr->s_name)] = 0;
+
+       return_section = bfd_make_section(abfd, name);
+    }
+
+    /* s_paddr is presumed to be = to s_vaddr */
+#define assign(to, from) return_section->to = hdr->from
+    assign(vma, s_vaddr);
+    /* assign (vma, s_vaddr); */
+    assign(size, s_size);
+    assign(filepos, s_scnptr);
+    assign(rel_filepos, s_relptr);
+    assign(reloc_count, s_nreloc);
+#ifdef I960
+    {
+       /* FIXME, use a temp var rather than alignment_power */
+       assign(alignment_power, s_align);
+       {
+           unsigned int    i;
+           for (i = 0; i < 32; i++) {
+               if ((1 << i) >= (int) (return_section->alignment_power)) {
+                   return_section->alignment_power = i;
+                   break;
+               }
+           }
+       }
+    }
+#endif
+    assign(line_filepos, s_lnnoptr);
+    /*
+       return_section->linesize =   hdr->s_nlnno * sizeof (struct lineno);
+    */
+
+#undef assign
+    return_section->lineno_count = hdr->s_nlnno;
+    return_section->userdata = NULL;
+    return_section->next = (asection *) NULL;
+    return_section->flags = 0;
+    if ((hdr->s_flags & STYP_TEXT) || (hdr->s_flags & STYP_DATA))
+       return_section->flags = (SEC_LOAD | SEC_ALLOC);
+    else if (hdr->s_flags & STYP_BSS)
+       return_section->flags = SEC_ALLOC;
+
+    if (hdr->s_nreloc != 0)
+       return_section->flags |= SEC_RELOC;
+    if (hdr->s_scnptr != 0)
+       return_section->flags |= SEC_HAS_CONTENTS;
+    return true;
+}
+static          boolean
+DEFUN(coff_mkobject,(abfd),
+      bfd            *abfd)
+{
+  set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type)));
+  if (coff_data(abfd) == 0) {
+    bfd_error = no_memory;
+    return false;
+  }
+  coff_data(abfd)->relocbase = 0;
+  return true;
+}
+
+static
+bfd_target     *
+DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
+    bfd            *abfd AND
+    unsigned        nscns AND
+  struct internal_filehdr *internal_f AND
+  struct internal_aouthdr *internal_a)
+{
+  coff_data_type *coff;
+
+  size_t          readsize;    /* length of file_info */
+  SCNHDR *external_sections;
+  
+  /* Build a play area */
+  if (coff_mkobject(abfd) != true)
+    return 0;
+  coff = coff_data(abfd);
+  
+  
+  external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ));
+  if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) {
+    goto fail;
+  }
+  
+  
+  
+  /* Now copy data as required; construct all asections etc */
+  coff->symbol_index_slew = 0;
+  coff->relocbase =0;
+  coff->raw_syment_count = 0;
+  coff->raw_linenos = 0;
+  coff->raw_syments = 0;
+  coff->sym_filepos =0;
+  coff->flags = internal_f->f_flags;
+  if (nscns != 0) {
+    unsigned int    i;
+    for (i = 0; i < nscns; i++) {
+      struct internal_scnhdr tmp;
+      bfd_coff_swap_scnhdr_in(abfd, external_sections + i, &tmp);
+      make_a_section_from_file(abfd,&tmp);
+    }
+  }
+  /* Determine the machine architecture and type.  */
+  abfd->obj_machine = 0;
+  switch (internal_f->f_magic) {
+#ifdef MIPS
+case  MIPS_MAGIC_1:
+case  MIPS_MAGIC_2:
+case  MIPS_MAGIC_3:
+    abfd->obj_arch = bfd_arch_mips;
+    abfd->obj_machine = 0;
+    break;
+#endif
+
+#ifdef MC68MAGIC
+  case MC68MAGIC:
+  case M68MAGIC:
+    abfd->obj_arch = bfd_arch_m68k;
+    abfd->obj_machine = 68020;
+    break;
+#endif
+#ifdef MC88MAGIC
+  case MC88MAGIC:
+  case MC88DMAGIC:
+  case MC88OMAGIC:
+    abfd->obj_arch = bfd_arch_m88k;
+    abfd->obj_machine = 88100;
+    break;
+#endif
+#ifdef I960
+#ifdef I960ROMAGIC
+  case I960ROMAGIC:
+  case I960RWMAGIC:
+    abfd->obj_arch = bfd_arch_i960;
+    switch (F_I960TYPE & internal_f->f_flags) 
+       {
+       default:
+       case F_I960CORE:
+         abfd->obj_machine = bfd_mach_i960_core;
+         break;
+       case F_I960KB:
+         abfd->obj_machine = bfd_mach_i960_kb_sb;
+         break;
+       case F_I960MC:
+         abfd->obj_machine = bfd_mach_i960_mc;
+         break;
+       case F_I960XA:
+         abfd->obj_machine = bfd_mach_i960_xa;
+         break;
+       case F_I960CA:
+         abfd->obj_machine = bfd_mach_i960_ca;
+         break;
+       case F_I960KA:
+         abfd->obj_machine = bfd_mach_i960_ka_sa;
+         break;
+         
+       }
+    break;
+#endif
+#endif
+    
+  default:                     /* Unreadable input file type */
+    abfd->obj_arch = bfd_arch_obscure;
+    break;
+  }
+  
+  if (!(internal_f->f_flags & F_RELFLG))
+    abfd->flags |= HAS_RELOC;
+  if ((internal_f->f_flags & F_EXEC))
+    abfd->flags |= EXEC_P;
+  if (!(internal_f->f_flags & F_LNNO))
+    abfd->flags |= HAS_LINENO;
+  if (!(internal_f->f_flags & F_LSYMS))
+    abfd->flags |= HAS_LOCALS;
+  
+  
+  bfd_get_symcount(abfd) = internal_f->f_nsyms;
+  if (internal_f->f_nsyms)
+    abfd->flags |= HAS_SYMS;
+  
+  coff->sym_filepos = internal_f->f_symptr;
+  
+  
+  
+  coff->symbols = (coff_symbol_type *) NULL;
+  bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0;
+  
+  return abfd->xvec;
+ fail:
+  bfd_release(abfd, coff);
+  return (bfd_target *)NULL;
+}
+
+static bfd_target *
+DEFUN(coff_object_p,(abfd),
+      bfd            *abfd)
+  {
+    int   nscns;
+    FILHDR filehdr;
+    AOUTHDR opthdr;
+    struct internal_filehdr internal_f;
+    struct internal_aouthdr internal_a;
+    
+    bfd_error = system_call_error;
+    
+    /* figure out how much to read */
+    if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ)
+      return 0;
+    
+    bfd_swap_filehdr_in(abfd, &filehdr, &internal_f);
+    
+    if (BADMAG(internal_f)) {
+      bfd_error = wrong_format;
+      return 0;
+    }
+    nscns =internal_f.f_nscns;
+    
+    if (internal_f.f_opthdr) {
+      if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) {
+       return 0;
+      }
+      bfd_swap_aouthdr_in(abfd, &opthdr, &internal_a);
+    }
+    
+    /* Seek past the opt hdr stuff */
+    bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET);
+    
+    /* if the optional header is NULL or not the correct size then
+      quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
+       and Intel 960 readwrite headers (I960WRMAGIC) is that the
+         optional header is of a different size.
+
+       But the mips keeps extra stuff in it's opthdr, so dont check
+       when doing that
+           */
+    
+#ifndef MIPS    
+    if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr)
+      return (bfd_target *)NULL;
+#endif
+    
+    return coff_real_object_p(abfd, nscns, &internal_f, &internal_a);
+  }
+
+
+
 
 /* 
 Takes a bfd and a symbol, returns a pointer to the coff specific area
@@ -566,7 +1172,7 @@ bfd            *abfd;
 #else
        n.r_type = q->howto->type;
 #endif
-       swap_reloc_out(abfd, &n, &dst);
+       bfd_swap_reloc_out(abfd, &n, &dst);
        bfd_write((PTR) &n, 1, RELSZ, abfd);
       }
     }
@@ -717,7 +1323,12 @@ unsigned       *magicp,
        }
        break;
 #endif
-       
+#ifdef MIPS
+      case bfd_arch_mips:
+         *magicp = MIPS_MAGIC_2;
+       return true;
+       break;
+#endif
 #ifdef MC68MAGIC
       case bfd_arch_m68k:
        *magicp = MC68MAGIC;
@@ -1008,11 +1619,9 @@ bfd            *abfd)
     { int   magic = 0;
       int   flags = 0;
       coff_set_flags(abfd, &magic, &flags);
-      internal_f.f_flags |= flags;
       internal_f.f_magic = magic;
       internal_f.f_flags = flags;
 
-
       /* ...and the "opt"hdr... */
 
 #ifdef I960
@@ -1051,12 +1660,12 @@ bfd            *abfd)
     return false;
     {
       FILHDR buff;
-      swap_filehdr_out(abfd, &internal_f, &buff);
-      bfd_write((PTR) &internal_f, 1, FILHSZ, abfd);
+      bfd_swap_filehdr_out(abfd, &internal_f, &buff);
+      bfd_write((PTR) &buff, 1, FILHSZ, abfd);
     }
   if (abfd->flags & EXEC_P) {
     AOUTHDR buff;
-    swap_aouthdr_out(abfd, &internal_a, &buff);
+    bfd_swap_aouthdr_out(abfd, &internal_a, &buff);
     bfd_write((PTR) &buff, 1, AOUTSZ, abfd);
   }
   return true;
@@ -1746,7 +2355,7 @@ DEFUN(coff_slurp_reloc_table,(abfd, asect, symbols),
           src++) {
        struct internal_reloc dst;
        asymbol        *ptr;
-       swap_reloc_in(abfd, src, &dst);
+       bfd_swap_reloc_in(abfd, src, &dst);
        dst.r_symndx += obj_symbol_slew(abfd);
        cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx];
        
This page took 0.031433 seconds and 4 git commands to generate.