Stricter prototyping, to force type conversions between 64-bit target and
[deliverable/binutils-gdb.git] / bfd / ieee.c
index 4aba2cc8c4dde8369e147031f3c4fe556795d1cf..301899618ebc363844b7f554884f9b63e0b57830 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for ieee-695 objects.
-   Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
 #include "obstack.h"
-#define obstack_chunk_alloc bfd_xmalloc
+#define obstack_chunk_alloc bfd_xmalloc_by_size_t
 #define obstack_chunk_free free
 
 /* Functions for writing to ieee files in the strange way that the
@@ -78,7 +78,7 @@ DEFUN(ieee_write_int,(abfd, value),
       bfd_vma value)
 {
   if (((unsigned)value) <= 127) {
-    ieee_write_byte(abfd, value);
+    ieee_write_byte(abfd, (bfd_byte)value);
   }
   else {
     unsigned int length;
@@ -95,16 +95,17 @@ DEFUN(ieee_write_int,(abfd, value),
     }
     else length = 1;
 
-    ieee_write_byte(abfd, (int)ieee_number_repeat_start_enum + length);
+    ieee_write_byte(abfd,
+                   (bfd_byte)((int)ieee_number_repeat_start_enum + length));
     switch (length) {
     case 4:
-      ieee_write_byte(abfd, value >> 24);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 24));
     case 3:
-      ieee_write_byte(abfd, value >> 16);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 16));
     case 2:
-      ieee_write_byte(abfd, value >> 8);
+      ieee_write_byte(abfd, (bfd_byte)(value >> 8));
     case 1:
-      ieee_write_byte(abfd, value);
+      ieee_write_byte(abfd, (bfd_byte)(value));
     }
   }
 }
@@ -116,16 +117,16 @@ DEFUN(ieee_write_id,(abfd, id),
 {
   size_t length = strlen(id);
   if (length >= 0 && length <= 127) {
-    ieee_write_byte(abfd, length);
+    ieee_write_byte(abfd, (bfd_byte)length);
   }
   else if (length < 255) {
     ieee_write_byte(abfd, ieee_extension_length_1_enum);
-    ieee_write_byte(abfd, length);
+    ieee_write_byte(abfd, (bfd_byte)length);
   }
   else if (length < 65535) {
     ieee_write_byte(abfd, ieee_extension_length_2_enum);
-    ieee_write_byte(abfd, length >> 8);
-    ieee_write_byte(abfd, length & 0xff);  
+    ieee_write_byte(abfd, (bfd_byte)(length >> 8));
+    ieee_write_byte(abfd, (bfd_byte)(length & 0xff));  
   }
   else {
     BFD_FAIL();
@@ -209,7 +210,7 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
   
      
 
-  if (symbol->section == &bfd_com_section
+  if (bfd_is_com_section (symbol->section)
       || symbol->section == &bfd_und_section) 
   {
     /* Def of a common symbol */
@@ -222,7 +223,8 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
     /* Ref to defined symbol - */
   
     ieee_write_byte(abfd, ieee_variable_R_enum);
-    ieee_write_byte(abfd, symbol->section->index + IEEE_SECTION_NUMBER_BASE);
+    ieee_write_byte(abfd, 
+       (bfd_byte) (symbol->section->index + IEEE_SECTION_NUMBER_BASE));
     term_count++;
     if (symbol->flags & BSF_GLOBAL) 
     {
@@ -235,8 +237,8 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
       /* This is a reference to a defined local symbol, 
         We can easily do a local as a section+offset */
       ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
-      ieee_write_byte(abfd, symbol->section->index +
-                     IEEE_SECTION_NUMBER_BASE);
+      ieee_write_byte(abfd, 
+         (bfd_byte)(symbol->section->index + IEEE_SECTION_NUMBER_BASE));
       ieee_write_int(abfd, symbol->value);
       term_count++;
 
@@ -252,7 +254,7 @@ DEFUN(ieee_write_expression,(abfd, value, symbol, pcrel, index),
   if(pcrel) {
       /* subtract the pc from here by asking for PC of this section*/
       ieee_write_byte(abfd, ieee_variable_P_enum);
-      ieee_write_byte(abfd, index  +IEEE_SECTION_NUMBER_BASE);
+      ieee_write_byte(abfd, (bfd_byte)(index+IEEE_SECTION_NUMBER_BASE));
       ieee_write_byte(abfd, ieee_function_minus_enum);
     }
 
@@ -771,7 +773,8 @@ DEFUN(ieee_get_symtab,(abfd, location),
   ieee_symbol_type *symp;
   static bfd dummy_bfd;
   static asymbol empty_symbol =
-  { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING , &bfd_abs_section};
+    /* the_bfd, name, value, attr, section */
+    { &dummy_bfd, " ieee empty", (symvalue)0, BSF_DEBUGGING, &bfd_abs_section};
 
   if (abfd->symcount) 
 {
@@ -844,8 +847,8 @@ DEFUN(ieee_slurp_sections,(abfd),
 {
   ieee_data_type *ieee = IEEE_DATA(abfd);
   file_ptr offset = ieee->w.r.section_part;
-
   asection *section = (asection *)NULL;
+  char *name;
 
   if (offset != 0) {
     bfd_byte section_type[3];
@@ -869,7 +872,7 @@ DEFUN(ieee_slurp_sections,(abfd),
              section_type[1] = this_byte(&(ieee->h));
              section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
              switch(section_type[1]) {
-             case 0xD3:
+             case 0xD3:                /* AS Absolute section attributes */
                next_byte(&(ieee->h));
                section_type[2] = this_byte(&(ieee->h));
                switch (section_type[2]) 
@@ -894,42 +897,39 @@ DEFUN(ieee_slurp_sections,(abfd),
                    }
              }
              break;
-           case 0xC3:
+           case 0xC3:          /* Named relocatable sections (type C) */
              section_type[1] = this_byte(&(ieee->h));
              section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
              switch (section_type[1]) {
-             case 0xD0:
-               /* Normal code */
+             case 0xD0:        /* Normal code (CP) */
                next_byte(&(ieee->h));
                section->flags |= SEC_LOAD | SEC_CODE;
                break;
-             case 0xC4:
+             case 0xC4:        /* Normal data (CD) */
                next_byte(&(ieee->h));
                section->flags |= SEC_LOAD  | SEC_DATA;
-               /* Normal data */
                break;
-             case 0xD2:
+             case 0xD2:        /* Normal rom data (CR) */
                next_byte(&(ieee->h));
-               /* Normal rom data */
                section->flags |= SEC_LOAD | SEC_ROM | SEC_DATA;
                break;
              default:
                break;
              }
            }
-           memcpy(section->name, read_id(&(ieee->h)),8);
-           /* Truncate sections to 8 chars */
-           if (strlen(section->name) > 8) 
+
+           /* Read section name, use it if non empty. */
+           name = read_id (&ieee->h);
+           if (name[0])
+             section->name = name;
+           
+           /* Skip these fields, which we don't care about */
            {
-             section->name[8] = 0;
-           }
-             { bfd_vma parent, brother, context;
+             bfd_vma parent, brother, context;
                parse_int(&(ieee->h), &parent);
                parse_int(&(ieee->h), &brother);
                parse_int(&(ieee->h), &context);
-             }
-
-
+           }
          }
        break;
       case ieee_section_alignment_enum:
@@ -1004,7 +1004,7 @@ DEFUN(ieee_archive_p,(abfd),
   boolean loop;
 
   unsigned int i;
-uint8e_type buffer[512];
+  unsigned char buffer[512];
   struct obstack ob;
   file_ptr buffer_offset = 0;
   ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
@@ -1122,8 +1122,9 @@ DEFUN(ieee_object_p,(abfd),
   char *processor;
   unsigned int part;
   ieee_data_type *ieee;
-  uint8e_type buffer[300];
+  unsigned char buffer[300];
   ieee_data_type *save = IEEE_DATA(abfd);
+
   abfd->tdata.ieee_data = 0;
   ieee_mkobject(abfd);
   
@@ -1198,7 +1199,7 @@ DEFUN(ieee_object_p,(abfd),
    quickly. We can work out how big the file is from the trailer
    record */
 
-  IEEE_DATA(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
+  IEEE_DATA(abfd)->h.first_byte = (unsigned char *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
                                            + 50);
   bfd_seek(abfd, (file_ptr) 0, SEEK_SET);
   bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1,   ieee->w.r.me_record+50,  abfd);
@@ -1211,6 +1212,18 @@ abfd->tdata.ieee_data = save;
   return (bfd_target *)NULL;
 }
 
+void 
+DEFUN(ieee_get_symbol_info,(ignore_abfd, symbol, ret),
+      bfd *ignore_abfd AND
+      asymbol *symbol AND
+      symbol_info *ret)
+{
+  bfd_symbol_info (symbol, ret);
+  if (symbol->name[0] == ' ')
+    ret->name = "* empty table entry ";
+  if (!symbol->section)
+    ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
+}
 
 void 
 DEFUN(ieee_print_symbol,(ignore_abfd, afile,  symbol, how),
@@ -1232,7 +1245,6 @@ DEFUN(ieee_print_symbol,(ignore_abfd, afile,  symbol, how),
 #endif
     BFD_FAIL();
     break;
-  case bfd_print_symbol_nm:
   case bfd_print_symbol_all:
       {
        CONST char *section_name = symbol->section == (asection *)NULL ?
@@ -1261,7 +1273,7 @@ static void
 DEFUN(do_one,(ieee, current_map, location_ptr,s),
       ieee_data_type *ieee AND
       ieee_per_section_type *current_map AND
-      uint8e_type *location_ptr AND
+      unsigned char *location_ptr AND
       asection *s)
 {
   switch (this_byte(&(ieee->h)))  
@@ -1491,7 +1503,6 @@ DEFUN(ieee_slurp_section_data,(abfd),
              case ieee_set_current_pc_enum & 0xff:
                  {
                    bfd_vma value;
-                   asection *dsection;
                    ieee_symbol_index_type symbol;
                    unsigned int extra;
                    boolean pcrel;
@@ -1523,7 +1534,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
                 */
 
              unsigned int iterations ;
-             uint8e_type *start ;
+             unsigned char *start ;
              next_byte(&(ieee->h));
              iterations = must_parse_int(&(ieee->h));
              start =  ieee->h.input_p;
@@ -1657,7 +1668,7 @@ DEFUN(ieee_write_section_part,(abfd),
       {
        
        ieee_write_byte(abfd, ieee_section_type_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
 
        if (abfd->flags & EXEC_P) 
        {
@@ -1697,18 +1708,19 @@ DEFUN(ieee_write_section_part,(abfd),
 #endif
        /* Alignment */
        ieee_write_byte(abfd, ieee_section_alignment_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE));
        ieee_write_int(abfd, 1 << s->alignment_power);
 
        /* Size */
        ieee_write_2bytes(abfd, ieee_section_size_enum);
-       ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+       ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
        ieee_write_int(abfd, s->_raw_size);
        if (abfd->flags & EXEC_P) {
            /* Relocateable sections don't have asl records */
            /* Vma */
            ieee_write_2bytes(abfd, ieee_section_base_address_enum);
-           ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+           ieee_write_byte(abfd,
+               (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
            ieee_write_int(abfd, s->vma);
          }
       }
@@ -1738,10 +1750,10 @@ DEFUN(do_with_relocs,(abfd, s),
 
   /* Output the section preheader */
   ieee_write_byte(abfd, ieee_set_current_section_enum);
-  ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+  ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
 
   ieee_write_twobyte(abfd, ieee_set_current_pc_enum);
-  ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+  ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
   ieee_write_expression(abfd, 0, s->symbol, 0, 0);
 
   if (relocs_to_go == 0) 
@@ -1780,7 +1792,7 @@ DEFUN(do_with_relocs,(abfd, s),
 
        if ((PTR)stream == (PTR)NULL) {
          /* Outputting a section without data, fill it up */
-         stream = (uint8e_type *)(bfd_alloc(abfd, s->_raw_size));
+         stream = (unsigned char *)(bfd_alloc(abfd, s->_raw_size));
          memset((PTR)stream, 0, s->_raw_size);
        }
        while (current_byte_index < s->_raw_size) {
@@ -1880,10 +1892,10 @@ DEFUN(do_as_repeat, (abfd, s),
 {
   if (s->_raw_size) {
     ieee_write_byte(abfd, ieee_set_current_section_enum);
-    ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+    ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
     ieee_write_byte(abfd, ieee_set_current_pc_enum >> 8);
     ieee_write_byte(abfd, ieee_set_current_pc_enum  & 0xff);
-    ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
+    ieee_write_byte(abfd, (bfd_byte)(s->index + IEEE_SECTION_NUMBER_BASE));
     ieee_write_int(abfd,  s->vma );
 
     ieee_write_byte(abfd,ieee_repeat_data_enum);
@@ -2606,7 +2618,7 @@ DEFUN(ieee_write_external_part,(abfd),
        p->value = reference_index;
        reference_index++;
       }
-      else if(p->section == &bfd_com_section) {
+      else if (bfd_is_com_section (p->section)) {
        /* This is a weak reference */
        ieee_write_byte(abfd, ieee_external_reference_enum);
        ieee_write_int(abfd, reference_index);
@@ -2675,7 +2687,7 @@ DEFUN(ieee_write_external_part,(abfd),
 }
 
 
-CONST static unsigned char exten[] = 
+static CONST unsigned char exten[] = 
   {
     0xf0, 0x20, 0x00,                                  
     0xf1, 0xce, 0x20, 0x00, 37, 3, 3,  /* Set version 3 rev 3          */
@@ -2683,7 +2695,7 @@ CONST static unsigned char exten[] =
     0xf1, 0xce, 0x20, 0x00, 38         /* set object type relocateable to x */
   };
 
-CONST static unsigned char envi[] =
+static CONST unsigned char envi[] =
   {
     0xf0, 0x21, 0x00,
 
@@ -2734,10 +2746,10 @@ DEFUN(ieee_write_object_contents,(abfd),
   ieee_write_byte(abfd, ieee_address_descriptor_enum);
 
   /* Bits per MAU */
-  ieee_write_byte(abfd, bfd_arch_bits_per_byte(abfd));
+  ieee_write_byte(abfd, (bfd_byte) (bfd_arch_bits_per_byte(abfd)));
   /* MAU's per address */
-  ieee_write_byte(abfd, bfd_arch_bits_per_address(abfd)  /
-                 bfd_arch_bits_per_byte(abfd));
+  ieee_write_byte(abfd,
+   (bfd_byte) (bfd_arch_bits_per_address(abfd) / bfd_arch_bits_per_byte(abfd)));
 
   old = bfd_tell(abfd);
   bfd_seek(abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
@@ -2790,7 +2802,7 @@ DEFUN(ieee_write_object_contents,(abfd),
 
   for (i= 0; i < N_W_VARIABLES; i++) {
     ieee_write_2bytes(abfd,ieee_assign_value_to_variable_enum);
-    ieee_write_byte(abfd, i);
+    ieee_write_byte(abfd, (bfd_byte) i);
     ieee_write_int5_out(abfd, ieee->w.offset[i]);
   }
   return true;
@@ -2967,6 +2979,12 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
 #define ieee_set_arch_mach bfd_default_set_arch_mach
 #define ieee_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define ieee_bfd_relax_section bfd_generic_relax_section
+#define ieee_bfd_seclet_link bfd_generic_seclet_link
+#define ieee_bfd_reloc_type_lookup \
+  ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
+#define ieee_bfd_make_debug_symbol \
+  ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
 /*SUPPRESS 460 */
 bfd_target ieee_vec =
 {
@@ -2983,8 +3001,12 @@ bfd_target ieee_vec =
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
     1,                         /* minimum alignment */
-_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
-_do_getb64, _do_putb64,  _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+    _do_getb32, _do_getb_signed_32, _do_putb32,
+    _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
+_do_getb64, _do_getb_signed_64, _do_putb64,
+    _do_getb32, _do_getb_signed_32, _do_putb32,
+    _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
 
   { _bfd_dummy_target,
      ieee_object_p,            /* bfd_check_format */
@@ -3003,6 +3025,7 @@ _do_getb64, _do_putb64,  _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs
     _bfd_write_archive_contents,
     bfd_false,
   },
-  JUMP_TABLE(ieee)
+  JUMP_TABLE(ieee),
+  (PTR) 0
 };
 
This page took 0.02967 seconds and 4 git commands to generate.