* binutils-all/readelf.exp: Don't regard mips*el-*-* as traditional
[deliverable/binutils-gdb.git] / bfd / oasys.c
index 4e543af181a617220a6820f823d756785f72e5db..12cefc7362a39780c9f4410ae2022295e8f8e823 100644 (file)
@@ -1,5 +1,6 @@
 /* BFD back-end for oasys objects.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999
+   Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -26,14 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "oasys.h"
 #include "liboasys.h"
 
-/* XXX - FIXME.  offsetof belongs in the system-specific files in
-   ../include/sys. */
-/* Define offsetof for those systems which lack it */
-
-#ifndef offsetof
-#define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
-#endif
-
 static boolean oasys_read_record PARAMS ((bfd *,
                                          oasys_record_union_type *));
 static boolean oasys_write_sections PARAMS ((bfd *));
@@ -118,10 +111,7 @@ oasys_slurp_symbol_table (abfd)
   data->strings = bfd_alloc (abfd, data->symbol_string_length);
 #endif
   if (!data->symbols || !data->strings)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   dest_defined = data->symbols + abfd->symcount - 1;
 
@@ -310,10 +300,7 @@ oasys_archive_p (abfd)
     oasys_module_table_type record;
 
     if (!ar || !module)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       return NULL;
-      }
+      return NULL;
 
     abfd->tdata.oasys_ar_data = ar;
     ar->module = module;
@@ -343,10 +330,7 @@ oasys_archive_p (abfd)
 
            module[i].name = bfd_alloc (abfd, 33);
            if (!module[i].name)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return NULL;
-             }
+             return NULL;
 
            memcpy (module[i].name, record_ext.mod_name, 33);
            filepos +=
@@ -372,10 +356,7 @@ oasys_archive_p (abfd)
 
            module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
            if (!module[i].name)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return NULL;
-             }
+             return NULL;
            if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
                          abfd)
                != record.module_name_size)
@@ -462,10 +443,7 @@ oasys_object_p (abfd)
              }
            buffer = bfd_alloc (abfd, 3);
            if (!buffer)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               goto fail;
-             }
+             goto fail;
            section_number = record.section.relb & RELOCATION_SECT_BITS;
            sprintf (buffer, "%u", section_number);
            s = bfd_make_section (abfd, buffer);
@@ -529,7 +507,7 @@ fail:
 
 static void
 oasys_get_symbol_info (ignore_abfd, symbol, ret)
-     bfd *ignore_abfd;
+     bfd *ignore_abfd ATTRIBUTE_UNUSED;
      asymbol *symbol;
      symbol_info *ret;
 {
@@ -539,8 +517,8 @@ oasys_get_symbol_info (ignore_abfd, symbol, ret)
 }
 
 static void
-oasys_print_symbol (ignore_abfd, afile, symbol, how)
-     bfd *ignore_abfd;
+oasys_print_symbol (abfd, afile, symbol, how)
+     bfd *abfd;
      PTR afile;
      asymbol *symbol;
      bfd_print_symbol_type how;
@@ -558,7 +536,7 @@ oasys_print_symbol (ignore_abfd, afile, symbol, how)
        CONST char *section_name = symbol->section == (asection *) NULL ?
        (CONST char *) "*abs" : symbol->section->name;
 
-       bfd_print_symbol_vandf ((PTR) file, symbol);
+       bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
 
        fprintf (file, " %-5s %s",
                 section_name,
@@ -633,10 +611,7 @@ oasys_slurp_section_data (abfd)
              {
                per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
                if (!per->data)
-                 {
-                   bfd_set_error (bfd_error_no_memory);
-                   return false;
-                 }
+                 return false;
                per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
                per->had_vma = false;
                per->initialized = true;
@@ -703,10 +678,7 @@ oasys_slurp_section_data (abfd)
                                  bfd_alloc (abfd,
                                             sizeof (oasys_reloc_type));
                                  if (!r)
-                                   {
-                                     bfd_set_error (bfd_error_no_memory);
-                                     return false;
-                                   }
+                                   return false;
                                  *(per->reloc_tail_ptr) = r;
                                  per->reloc_tail_ptr = &r->next;
                                  r->next = (oasys_reloc_type *) NULL;
@@ -750,10 +722,7 @@ oasys_slurp_section_data (abfd)
                                  bfd_alloc (abfd,
                                             sizeof (oasys_reloc_type));
                                  if (!r)
-                                   {
-                                     bfd_set_error (bfd_error_no_memory);
-                                     return false;
-                                   }
+                                   return false;
                                  *(per->reloc_tail_ptr) = r;
                                  per->reloc_tail_ptr = &r->next;
                                  r->next = (oasys_reloc_type *) NULL;
@@ -819,10 +788,7 @@ oasys_new_section_hook (abfd, newsect)
   newsect->used_by_bfd = (PTR)
     bfd_alloc (abfd, sizeof (oasys_per_section_type));
   if (!newsect->used_by_bfd)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   oasys_per_section (newsect)->data = (bfd_byte *) NULL;
   oasys_per_section (newsect)->section = newsect;
   oasys_per_section (newsect)->offset = 0;
@@ -870,10 +836,10 @@ oasys_get_section_contents (abfd, section, location, offset, count)
 
 long
 oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols)
-     bfd *ignore_abfd;
+     bfd *ignore_abfd ATTRIBUTE_UNUSED;
      sec_ptr section;
      arelent **relptr;
-     asymbol **symbols;
+     asymbol **symbols ATTRIBUTE_UNUSED;
 {
   unsigned int reloc_count = 0;
   oasys_reloc_type *src = (oasys_reloc_type *) (section->relocation);
@@ -1036,8 +1002,11 @@ oasys_write_sections (abfd)
 
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
     {
-      if (!isdigit (s->name[0]))
+      if (!isdigit ((unsigned char) s->name[0]))
        {
+         (*_bfd_error_handler)
+           (_("%s: can not represent section `%s' in oasys"),
+            bfd_get_filename (abfd), s->name);
          bfd_set_error (bfd_error_nonrepresentable_section);
          return false;
        }
@@ -1345,10 +1314,7 @@ oasys_set_section_contents (abfd, section, location, offset, count)
          oasys_per_section (section)->data =
            (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size));
          if (!oasys_per_section (section)->data)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
        }
       (void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
                     location,
@@ -1373,10 +1339,7 @@ oasys_make_empty_symbol (abfd)
   oasys_symbol_type *new =
   (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
   if (!new)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   new->symbol.the_bfd = abfd;
   return &new->symbol;
 }
@@ -1432,13 +1395,13 @@ oasys_find_nearest_line (abfd,
                         filename_ptr,
                         functionname_ptr,
                         line_ptr)
-     bfd *abfd;
-     asection *section;
-     asymbol **symbols;
-     bfd_vma offset;
-     char **filename_ptr;
-     char **functionname_ptr;
-     unsigned int *line_ptr;
+     bfd *abfd ATTRIBUTE_UNUSED;
+     asection *section ATTRIBUTE_UNUSED;
+     asymbol **symbols ATTRIBUTE_UNUSED;
+     bfd_vma offset ATTRIBUTE_UNUSED;
+     char **filename_ptr ATTRIBUTE_UNUSED;
+     char **functionname_ptr ATTRIBUTE_UNUSED;
+     unsigned int *line_ptr ATTRIBUTE_UNUSED;
 {
   return false;
 
@@ -1465,8 +1428,8 @@ oasys_generic_stat_arch_elt (abfd, buf)
 
 static int
 oasys_sizeof_headers (abfd, exec)
-     bfd *abfd;
-     boolean exec;
+     bfd *abfd ATTRIBUTE_UNUSED;
+     boolean exec ATTRIBUTE_UNUSED;
 {
   return 0;
 }
@@ -1484,9 +1447,11 @@ oasys_sizeof_headers (abfd, exec)
   ((boolean (*) \
     PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
    bfd_true)
+#define oasys_read_ar_hdr bfd_nullvoidptr
+#define oasys_get_elt_at_index _bfd_generic_get_elt_at_index
 #define oasys_update_armap_timestamp bfd_true
 
-#define oasys_bfd_is_local_label bfd_generic_is_local_label
+#define oasys_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define oasys_get_lineno _bfd_nosymbols_get_lineno
 #define oasys_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 #define oasys_read_minisymbols _bfd_generic_read_minisymbols
@@ -1496,9 +1461,14 @@ oasys_sizeof_headers (abfd, exec)
 
 #define oasys_set_arch_mach bfd_default_set_arch_mach
 
+#define oasys_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 #define oasys_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
 #define oasys_bfd_relax_section bfd_generic_relax_section
+#define oasys_bfd_gc_sections bfd_generic_gc_sections
+#define oasys_bfd_merge_sections bfd_generic_merge_sections
 #define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define oasys_bfd_final_link _bfd_generic_final_link
@@ -1509,8 +1479,8 @@ const bfd_target oasys_vec =
 {
   "oasys",                     /* name */
   bfd_target_oasys_flavour,
-  true,                                /* target byte order */
-  true,                                /* target headers byte order */
+  BFD_ENDIAN_BIG,              /* target byte order */
+  BFD_ENDIAN_BIG,              /* target headers byte order */
   (HAS_RELOC | EXEC_P |                /* object flags */
    HAS_LINENO | HAS_DEBUG |
    HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
@@ -1519,7 +1489,6 @@ const bfd_target oasys_vec =
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  1,                           /* minimum alignment */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* data */
@@ -1555,5 +1524,7 @@ const bfd_target oasys_vec =
   BFD_JUMP_TABLE_LINK (oasys),
   BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
+  NULL,
+  
   (PTR) 0
 };
This page took 0.028126 seconds and 4 git commands to generate.